1

There is a "Continue shopping" button in the checkout, which points to the homepage in default installation, if I am not mistaken.

The URL of "Continue shopping" button is set in checkout/cart template by function getContinueShoppingUrl() defined in checkout/cart block.

  1. How to modify the URL of this button the most elegant way ?
  2. Where in your opinion should this button link to ?
0

1 Answer 1

5

You have 2 options of changing this url (actually there are more but 2 of them are easier).
The first one, if you want always a specific url you can use the layout file inside the cart block definition this:

<action method="setContinueShoppingUrl"><url>Some/url</url></action>

But this can result into issues. It is better to create your own helper that has a method getContinueUrl that returns the desired url and modify the markup above to

<action method="setContinueShoppingUrl"><url helper="helper_alias/getContinueUrl" /></action>

Or you can create an observer that set's the url on the block:

Mage::app()->getLayout()->getBlock('checkout.cart')->setContinueShoppingUrl('URL HERE');

The second option is to create an observer that sets the url in session. This can be used if you want a dynamic continue url. Add this in your observer.

Mage::getSingleton('checkout/session')->setContinueShoppingUrl('URL HERE')

There is always the 3rd option of rewriting the cart block but there is no need for that when you have the 2 options above.

And as far as Where should this button link to? I think this is opinion based. It can link to the last visited category, to the homepage, to one of the crosssels products of the last product added to cart, to the advanced search.

2
  • Great, thanks ! I am using the first option with xml and helper. Only that there is a small typo in <action method="setContinueShoppingUrl"><url helper="helper_alias/getContinueUrl"/></action> - you should put the "/" in the end of the <url>
    – bogatyrjov
    Sep 26, 2013 at 9:30
  • @JevgeniBogatyrjov. Thanks for the correction. It's done.
    – Marius
    Sep 26, 2013 at 9:36

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