Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Set Continue Shopping button URL
 
RichardWork
Jr. Member
 
Total Posts:  11
Joined:  2008-04-17
 

How do you set the URL that the continue shopping button sends the user to from the Shopping Cart page, On my installation it goes back to the /index.php page.

There is a call to $this->getContinueShoppingUrl() in cart.phtml, which looks like it calls getData with “continue_shopping_url”, not sure where this goes.

I am using Magento version 1.0.19870.1.

 
Magento Community Magento Community
Magento Community
Magento Community
 
CENOBITE
Jr. Member
 
Total Posts:  8
Joined:  2008-07-07
 

Did you find a solution for this issue?
I encounter the same problem. The “continue shooping” button redirects to the index page instead of the product last viewed.

 
Magento Community Magento Community
Magento Community
Magento Community
 
weckl
Member
 
Total Posts:  50
Joined:  2008-07-13
Singapore
 

Hi,

I also need a solution for this.. any clues? Magento team?

 
Magento Community Magento Community
Magento Community
Magento Community
 
weckl
Member
 
Total Posts:  50
Joined:  2008-07-13
Singapore
 

Found the solution....

open to app/code/core/Mage/Checkout/Helper/Cart.php

Comment out line 60 and uncomment line 59

public function getAddUrl($product$additional = array())
    
{
        
/**
         * Identify continue shopping url
         */
        
if ($currentProduct Mage::registry('current_product')) {
            
/**
             * go to product view page
             */
            
$continueShoppingUrl $currentProduct->getProductUrl();
        
elseif ($currentCategory Mage::registry('current_category')) {
            
/**
             * go to category view page
             */
          
            
$continueShoppingUrl $currentCategory->getUrl();
           
// $continueShoppingUrl = $this->_getRequest()->getRequestUri();
        
else {
            $continueShoppingUrl 
$this->_getUrl('*/*/*', array('_current'=>true));
        
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
CoopNYC
Jr. Member
 
Total Posts:  1
Joined:  2008-09-11
 

The file outlined here is different than the one included in version 1.1.6. Does anyone have details for a solution in the current version?

In certain cases the continue shopping button takes me to the home page of the site and other times it takes me to an item details page. I want it always to go to a specific category page.

Any way to force this to happen?

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
abovethefold
Jr. Member
 
Total Posts:  13
Joined:  2008-03-16
Boston, MA
 

How do you change the variable to a predefined URL? For example, I would like to have all the continue shopping href’s be /products.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tansau
Member
 
Avatar
Total Posts:  35
Joined:  2008-02-28
Heart of Dixie, USA
 
CoopNYC - 07 October 2008 09:36 PM

The file outlined here is different than the one included in version 1.1.6. Does anyone have details for a solution in the current version?

In certain cases the continue shopping button takes me to the home page of the site and other times it takes me to an item details page. I want it always to go to a specific category page.

These notes refer to 1.1.8, but may help other versions.

If you have a valid session, the getContinueShoppingUrl() value will be the page that you were on prior to adding something to your cart. If you add an item to your cart from the product’s page, you’ll return there. If you added an item from a catalog view, category or filtered list, you should return there as well.

If you click into your shopping cart using the top links or other path that does not include adding an item to your cart, then by default the “continue shopping” button will take you back to the site home page. If you want to change that behavior to go to a specific page, you’ll need to modify the following file:

app/code/core/Mage/Checkout/Block/Cart.php

If, for instance, you want to direct visitors to your “Products” category, defined with the URL string “products”, modify the getContinueShoppingUrl() values to look like the one shown below:

public function getContinueShoppingUrl()
    
{
        $url 
$this->getData('continue_shopping_url');
        if (
is_null($url)) {
            $url 
Mage::getSingleton('checkout/session')->getContinueShoppingUrl(true);
            if (!
$url{
                $url 
Mage::getUrl('products');
            
}
            $this
->setData('continue_shopping_url'$url);
        
}
        
return $url;
    
}

The change is to this line:
$url = Mage::getUrl(’products’); to include “products” where it was formerly blank.

Hope this is helpful!

 
Magento Community Magento Community
Magento Community
Magento Community
 
geoffT
Jr. Member
 
Avatar
Total Posts:  23
Joined:  2008-05-22
 

Tansau-

Awesome.  Worked like a charm.  Thanks for the post.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Gabriel25ny
Jr. Member
 
Total Posts:  4
Joined:  2009-04-30
 

Thank you for sharing.

Gabe

 
Magento Community Magento Community
Magento Community
Magento Community
 
BigBlock
Sr. Member
 
Avatar
Total Posts:  85
Joined:  2007-10-06
 
Tansau - 16 December 2008 11:26 AM

CoopNYC - 07 October 2008 09:36 PM
The file outlined here is different than the one included in version 1.1.6. Does anyone have details for a solution in the current version?

In certain cases the continue shopping button takes me to the home page of the site and other times it takes me to an item details page. I want it always to go to a specific category page.

These notes refer to 1.1.8, but may help other versions.

If you have a valid session, the getContinueShoppingUrl() value will be the page that you were on prior to adding something to your cart. If you add an item to your cart from the product’s page, you’ll return there. If you added an item from a catalog view, category or filtered list, you should return there as well.

If you click into your shopping cart using the top links or other path that does not include adding an item to your cart, then by default the “continue shopping” button will take you back to the site home page. If you want to change that behavior to go to a specific page, you’ll need to modify the following file:

app/code/core/Mage/Checkout/Block/Cart.php

If, for instance, you want to direct visitors to your “Products” category, defined with the URL string “products”, modify the getContinueShoppingUrl() values to look like the one shown below:

public function getContinueShoppingUrl()
    
{
        $url 
$this->getData('continue_shopping_url');
        if (
is_null($url)) {
            $url 
Mage::getSingleton('checkout/session')->getContinueShoppingUrl(true);
            if (!
$url{
                $url 
Mage::getUrl('products');
            
}
            $this
->setData('continue_shopping_url'$url);
        
}
        
return $url;
    
}

The change is to this line:
$url = Mage::getUrl(’products’); to include “products” where it was formerly blank.

Hope this is helpful!

Careful with that one ...  it’s if there is no URL, so if users are coming from a product page to the cart and click “continue” they will be redirected back to the product page anyway [because they have a return url] this way does work for users who click on the “my cart” then continue - then they are redirected to whatever page you specify here....

So if you want them to always goto a different page - remove the conditional. 

//if (!$url) {
            //    $url = Mage::getUrl('');
            //}
            $url Mage::getUrl('shop.html');
 
Magento Community Magento Community
Magento Community
Magento Community
 
neonhomer
Jr. Member
 
Total Posts:  2
Joined:  2009-06-24
 

I see the issue here has been resolved, but under System -> Configuration -> Web -> Unsecure tab, couldn’t you just change the “Base Link URL”? It seems nicer to do that than go all the way into the code. The only issue i’m seeing is you have to have the Search Engines Optimization -> Use Web Server Rewrites turned on.

Nevermind, i see that changing that Base Link URL breaks links to things like the checkout, etc.

 
Magento Community Magento Community
Magento Community
Magento Community
 
KarenKilroy
Member
 
Avatar
Total Posts:  39
Joined:  2009-02-26
 

//if (!$url) {
            //    $url = Mage::getUrl('');
            //}
            $url Mage::getUrl('shop.html');

*****

This got me close but didn’t completely work - it added a trailing slash. To remove it, I added one more line of code:

//            if (!$url) {
//                $url = Mage::getUrl();
//            }
             $url Mage::getURL('shop.html');
             
$url rtrim($url'/');

Thanks! Karen

 
Magento Community Magento Community
Magento Community
Magento Community
 
firstimpression
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2009-03-02
Glossop, Derbyshire, UK
 
Karen Kilroy - 31 July 2009 07:08 AM

//if (!$url) {
            //    $url = Mage::getUrl('');
            //}
            $url Mage::getUrl('shop.html');

*****

This got me close but didn’t completely work - it added a trailing slash. To remove it, I added one more line of code:

//            if (!$url) {
//                $url = Mage::getUrl();
//            }
             $url Mage::getURL('shop.html');
             
$url rtrim($url'/');

Thanks! Karen

Hi Karen,

I am getting the same problem with a trailing slash, I have tried your code but it still does the same thing, am I missing something?

 
Magento Community Magento Community
Magento Community
Magento Community
 
KarenKilroy
Member
 
Avatar
Total Posts:  39
Joined:  2009-02-26
 

Hi firstimpression,

my first-cup-of-coffee reaction is, did you clear your cache?
tx
Karen

 
Magento Community Magento Community
Magento Community
Magento Community
 
firstimpression
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2009-03-02
Glossop, Derbyshire, UK
 

Still no difference after a cache refresh, here is my code, have I included the changes in the correct brackets?

public function getContinueShoppingUrl()
    
{
        $url 
$this->getData('continue_shopping_url');
        if (
is_null($url)) {
            $url 
Mage::getSingleton('checkout/session')->getContinueShoppingUrl(true);
          
//  if (!$url) {
              //  $url = Mage::getUrl();
            //}
            
            
$url Mage::getURL('shop.html');
             
$url rtrim($url'/');
             
            
$this->setData('continue_shopping_url'$url);
        
}
        
return $url;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
rickahontas
Member
 
Total Posts:  64
Joined:  2009-09-11
oakland, ca
 

This code is working for me:

public function getContinueShoppingUrl()
    
{
        $url 
$this->getData('continue_shopping_url');
        if (
is_null($url)) {
            $url 
Mage::getSingleton('checkout/session')->getContinueShoppingUrl(true);
            if (!
$url{
                $url 
Mage::getUrl('shop.html');
                
$url rtrim($url'/');
            
}
            $this
->setData('continue_shopping_url'$url);
        
}
        
return $url;
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2