首页 > 其他分享 >Magento : Make 'Continue Shopping' button redirect to the product index page

Magento : Make 'Continue Shopping' button redirect to the product index page

时间:2023-03-27 18:01:03浏览次数:36  
标签:redirect index product Shopping button Continue __ getContinueShoppingUrl


Magento : Make 'Continue Shopping' button redirect to the last-added-to-cart product's category



 



Edit cart.phtml and replace following code

<?php if($this->getContinueShoppingUrl()): ?>
    <button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button btn-continue" οnclick="setLocation('<?php echo $this->getContinueShoppingUrl(); ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
<?php endif; ?>

 


with



<?php
    $lastProductAddedToCartId = Mage::getSingleton('checkout/session')->getLastAddedProductId();
    if($lastProductAddedToCartId) {
        $productCategoryIdsArray = Mage::getModel('catalog/product')->load($lastProductAddedToCartId)->getCategoryIds();
        $continueShoppingCategoryUrl = Mage::getModel('catalog/category')->load($productCategoryIdsArray[0])->getUrl();
    }
?>
<?php if($this->getContinueShoppingUrl()): ?>
        <button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button btn-continue" οnclick="setLocation('<?php echo (isset($continueShoppingCategoryUrl)) ? $continueShoppingCategoryUrl : $this->getContinueShoppingUrl(); ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
 <?php endif; ?>



 

标签:redirect,index,product,Shopping,button,Continue,__,getContinueShoppingUrl
From: https://blog.51cto.com/u_8895844/6152733

相关文章