News:

Looking for documentation? Take a look on our wiki

Main Menu

"Ask a question" to only "Shoppers who bought the product"

Started by Janz, August 19, 2012, 15:59:28 PM

Previous topic - Next topic

Janz

Hi,

I tried to find this but can not figure out how to do it... Please how to show "Ask a question link" to only "Shoppers who bought the product" ?

Thanks a lot!
Regards
Janz

bytelord

Hello,

I can give you an idea that comes in my mind not a guideline where may be helps you out.

On the backend comment/review system there is an option that says  Enable Review System for ->  - Shoppers who bought the product and also Enable Rating System for  --> -Shoppers who bought the product. So you could use allowrating or allowreview to "trick" the system.

You can check the default_reviews.php to see how that accomplished and use the same code or take an idea.
I think it uses the rating model ($ratingModel) if i am not mistaken.
With that you have the option that only shoppers that buy that product can ask a question and review the product, that's all! :)

So it could be like the following code using as example the allowReview (code hasn't been tested):


<?php if($this->allowReview ) {

if (
VmConfig::get('ask_question'1) == 1) { ?>

    <div class="ask-a-question">
       <a class="ask-a-question" href="<?php echo $url ?>" ><?php echo JText::_('COM_VIRTUEMART_PRODUCT_ENQUIRY_LBL'?></a>
     </div>
<?php 

?>


This is just an idea ... hopefully you enabled rating/comment system only for your shoppers/users that buy the product :)

Hope it helps you out!

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

Janz

Wow bytelord,

thank you very much for your kind reply! VERY appreciated!
I have had enabled rating/comment system only for your shoppers/users that bought the product and will try to edit the file as you suggested sometime today.
Will keep you updated ;)
Thanks a lot!

Edited:
PS: Do you think the same rules would apply for the "additional description" ? Which file would it be please? I tried to asked this here: http://forum.virtuemart.net/index.php?topic=106080.0
Thanks a lot :)

bytelord

Hello,

START MAY BE OUT OF TOPIC
I take a look this morning in rating model and i find the function that show if a user bought that product, but Unfortunately is a private function and not a public one. In case you are interested (i say that in case that you need to separate the rating/review backend configuration from the "who bought the product" only) you have to hack the core (i am not suggesting it) and change the rating model (administrator\components\com_virtuemart\models\ratings.php) about line 450 to change the show function from private to public, then you will be able to use it from other  files/models to represent it as you wish (based on MVC model). In case you do that hack you can go to product details page and the following code somewhere at he beginning of the file (after a <?php):

$ratingModel = VmModel::getModel('ratings');
$bought_prd =  $ratingModel->show($this->product->virtuemart_product_id, 'bought');


the $bought_prg has the true/false value if the user is registered and also if bought the product, so if a user bought the product and is also registered that value will be '1' (TRUE), after that anywhere in your code you with an if statement like  if ($bought_prd) { //your code }

I am NOT suggesting you to hack the core files because maybe this i am writing above cause other issues that i am not aware.

May be Milbo (who is and the author of show function) take a look on that post and move show function from rating model to shopfunctions or product model as public one so anyone can use it, it will be a great feature!!
END OF MAY BE OUT OF TOPIC


Back to our topic. Yes you can use that code on my previous post everywhere you want in the product details, just an if statement, nothing else. On your question, "additional description" could be a custom field, so before you print it out use the if statement, like

<?php if($this->allowReview ) {
     // your additional details code ... may be placed in a tab :)
} ?>

Hope helps you out.

Regards


Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

Janz

Thanks a lot Bytelord,

I'll try what you suggested and reply as soon as I test it.
Really appreciated!
All the best!
Regards
J.