0

I'm looking to use a "View Details" button instead of add to cart because the latter isn't always working with my Full Page Cache extension (it instead just shows you that your cart is empty when you try to add something), so for now, until I find a fix, I would like to use "View Details" as it should work all the time.

What method would I use within the <button onclick=""> so that it links to the item's details?

Here is the current code in my template file:

<p>
    <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')">
        <span><span><?php echo $this->__('Add to Cart') ?></span></span>
    </button>
</p>
3
<a href="<?php echo $_product->getProductUrl() ?>"><?php echo $this->__('View Details')?></a>

Where $_product is the current product you are displaying.

If you want to use a button:

<button type="button" onclick="setLocation('<?php echo $_product->getProductUrl() ?>')"><?php echo $this->__('View Details')?></button>
| improve this answer | |
  • Also, j/w which class is getProductUrl() in? – Jason Yaraghi Nov 24 '15 at 15:32
  • 1
    Mage_Catalog_Model_Product – Marius Nov 24 '15 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.