Search
Other Advanced Module Manager questions
Forum

Display module if virtuemart product price above 100€

George Angelopoulos's Avatar George Angelopoulos
I've used advance module manager for the past 8-10 years and only stuck with the default options as I'm not a developer myself.
I now have the need to display a module only to the products that have a price above 100€.
How should I write the syntax? Could somebody help?

Best Regards,
George
Peter van Westen's Avatar Peter van Westen ADMIN
You can use the custom PHP assignment for this.
You will need to ask VirtueMart if they can provide you with a code snippet you can use to check that information.

So the code needs to grab the current active product and read out its price.
Then return a true or false value based on whether it is above 100 or not.
Please post a rating at the Joomla! Extensions Directory
George Angelopoulos's Avatar George Angelopoulos
Thank you Peter!
This was the fastest response ever.
Custom PHP assignment is what I've tried so far but unfortunately I'm only good at copy-pasting.
I tried this code after reading your documentation and my developer's code for the product details page but it didn't work:
if( $this->product->salesPrice; > '100' ) {
   return true;
} else {
   return false;
}

I don't know if this is correct or if I should express it in another way.
Peter van Westen's Avatar Peter van Westen ADMIN
You can't just use $this->product anywhere in PHP outside the component scope.
So the code needs to grab the current active product and read out its price.
Again, you should ask Virtuemart about that. It is outside my support to figure out what custom PHP code you need for another 3rd party extension.

Once you have the product object (that contains a salesPrice) you could end the code with:
return $product->salesPrice > 100;

Or if VM can provide a way to just get the salesPrice directly, you could do:
$price = ...[whatever VM code you need]...

return $price > 100;
Please post a rating at the Joomla! Extensions Directory
George Angelopoulos's Avatar George Angelopoulos
Thank you very much Peter.
I think I have understood the reason why it doesn't work.
I'll try and find a solution in virtuemart forums or the developer will undertake the task as soon as he returns from vacations 🙂

Again thank you very much and congratulations for all the great products you have created!
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription