Setting the ‘continue shopping’ URL to last product’s category page in magento
19May10
Here is a code snippet for setting the ‘Continue Shopping’ location to the category listing page of the last product added to the cart. Open the template/checkout/cart.phtml file in your active theme. Place the following code in the foreach loop
(ie. after this line of code)
<?php foreach($this->getItems() as $_item): ?>
that generates the products list in the cart.
<?php
$_categories = $_item->getProduct()->getCategoryIds();
$_category = Mage::getModel(‘catalog/category’)->load($_categories[0]);
$url = $this->getUrl($_category->getUrlPath());
Mage::getSingleton(‘checkout/session’)->setContinueShoppingUrl($url);
?>
You are done!
Advertisement
Filed under: Magentocommerce, PHP | Leave a Comment
Tags: magento, php
No Responses Yet to “Setting the ‘continue shopping’ URL to last product’s category page in magento”