Scroll Top

Changing the Continue Shopping Button URL in Magento

magento ecommerce For people using the Magento ecommerce framework (v.1.6.1 used in this example) you have seen that once you go to view your shopping cart and hit the continue shopping button, it takes you back to the last product you viewed, and not the last category, as would be logical.

To fix this issue find the file :
app/design/frontend/base/default/template/checkout/cart.phtml

If you have a theme installed, you should look here first:
app/design/frontend/default/YOUR THEME NAME/template/checkout/cart.phtml

Now that you have the file you need, look for this code that starts the loop for every item in the cart(line 109 on my version):

<?php foreach($this->getItems() as $_item): ?>

Below that input the following code that will change the path of the continue shopping button by setting the product url to the category url inside the loop:

<?php

$_categories = $_item->getProduct()->getCategoryIds();
$_category = Mage::getModel(‘catalog/category’)->load($_categories[0]);
$url = $this->getUrl($_category->getUrlPath());
Mage::getSingleton(‘checkout/session’)->setContinueShoppingUrl($url);

?>

If you have multiple products it will always set the url to the last product.

If you have need for a website designer, call us today 509-475-1177

Comments (1)

Found you website looking to solve exactly the same issue. Thank you for this guide, I am sure a lot of other people would want to change that button too.

Comments are closed.