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:

    <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>

1 Answer 1

<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>
  • Also, j/w which class is getProductUrl() in?
    – Adrift
    Commented Nov 24, 2015 at 15:32
  • 1
    – Marius
    Commented Nov 24, 2015 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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