I've tried to figure out how to do this but just can't work it out, I've tried searching on here, Google and through the Virtuemart forums to no success.
I'm trying to display the Add To Cart button that is on the Product Details page on the Category browse page. I did this previously in Virtuemart 1.1 by using the following code:
<?php echo $form_addtocart ?>
However upon trying to use this same code in Virtuemart 2 I am getting no result, even though their guide still states this as far as I can see: http://virtuemart.net/documentation/Developer_Manual/Modifying_the_Layout.html
I have tried copying the exact code from the products page but that doesn't work either, the code is:
<?php
// Add To Cart Button
if (!VmConfig::get('use_as_catalog', 0) and !empty($this->product->prices)) {
echo $this->loadTemplate('addtocart');
} // Add To Cart Button END
?>
The files I am overriding are located at:
/components/com_virtuemart/views/category/tmpl/default.php (the Category template)
/components/com_virtuemart/views/productdetails/tmpl/default.php (the Product page that the button is from)
=====
Apologies if I am overlooking something simple or if I have left out any necessary information.
Regards, alexnire.
With VM, it could be a ton of things. If you don't have a debugging tool, just add these lines to see if the conditions are being met (as mentioned by Damien):
echo "vmConfig says: |".VmConfig::get('use_as_catalog', 0)."|";
echo ", Product has prices?: |".$this->product->prices."|";
// Add To Cart Button
if (!VmConfig::get('use_as_catalog', 0) and !empty($this->product->prices)) {
echo $this->loadTemplate('addtocart');
} // Add To Cart Button END
If both come back as true, then it's the template for the addtocart button.