Modifying the redirect after editing a product in the cart Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Removing the “minimum purchase” noticeDisable redirect after product add to basketCreate invoice and shipment in magento via cron based on store view and order ageExclude a specific categoryWrong tax calculation (hiddentax and rowtax) for b2b on Magento CE 1.9.1.0Magento email queue problemsShopping cart is empty after cancel the payment in magento-1.9.1.1Magento 2: Add a product to the cart programmaticallySOLVED Error “Cannot add the item to shopping cart.” after upgrading to Magento 1.9.3.9Magento 2 not passing minimum QTY when adding related products to cart

Would I be safe to drive a 23 year old truck for 7 hours / 450 miles?

Why do people think Winterfell crypts is the safest place for women, children & old people?

Coin Game with infinite paradox

Are bags of holding fireproof?

Weaponising the Grasp-at-a-Distance spell

Who's this lady in the war room?

Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?

lm and glm function in R

A German immigrant ancestor has a "Registration Affidavit of Alien Enemy" on file. What does that mean exactly?

Are Flameskulls resistant to magical piercing damage?

Unix AIX passing variable and arguments to expect and spawn

Why does my GNOME settings mention "Moto C Plus"?

How to mute a string and play another at the same time

How to ask rejected full-time candidates to apply to teach individual courses?

What were wait-states, and why was it only an issue for PCs?

Does the Pact of the Blade warlock feature allow me to customize the properties of the pact weapon I create?

Does Prince Arnaud cause someone holding the Princess to lose?

Like totally amazing interchangeable sister outfit accessory swapping or whatever

Determine the generator of an ideal of ring of integers

When speaking, how do you change your mind mid-sentence?

Can I ask an author to send me his ebook?

Etymology of 見舞い

Should man-made satellites feature an intelligent inverted "cow catcher"?

Can I take recommendation from someone I met at a conference?



Modifying the redirect after editing a product in the cart



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Removing the “minimum purchase” noticeDisable redirect after product add to basketCreate invoice and shipment in magento via cron based on store view and order ageExclude a specific categoryWrong tax calculation (hiddentax and rowtax) for b2b on Magento CE 1.9.1.0Magento email queue problemsShopping cart is empty after cancel the payment in magento-1.9.1.1Magento 2: Add a product to the cart programmaticallySOLVED Error “Cannot add the item to shopping cart.” after upgrading to Magento 1.9.3.9Magento 2 not passing minimum QTY when adding related products to cart



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I have a problem modifying a redirect in magento CE 1.9.2.



Let's say a customer has a configurable product in the cart, and would like to edit that product (ie. changing color or size or something).



After changing the options and clicking the 'update cart' button I want the customer to stay on the same page (ie. the edit product page). However magento always redirect back to the cart page.



I think I've found source of the problem, in CartController.php from the Checkout module:



/**
* Update product configuration for a cart item
*/
public function updateItemOptionsAction()

$cart = $this->_getCart();
$id = (int) $this->getRequest()->getParam('id');
$params = $this->getRequest()->getParams();

if (!isset($params['options']))
$params['options'] = array();

try
if (isset($params['qty']))
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
$params['qty'] = $filter->filter($params['qty']);


$quoteItem = $cart->getQuote()->getItemById($id);
if (!$quoteItem)
Mage::throwException($this->__('Quote item is not found.'));


$item = $cart->updateItem($id, new Varien_Object($params));
if (is_string($item))
Mage::throwException($item);

if ($item->getHasError())
Mage::throwException($item->getMessage());


$related = $this->getRequest()->getParam('related_product');
if (!empty($related))
$cart->addProductsByIds(explode(',', $related));


$cart->save();

$this->_getSession()->setCartWasUpdated(true);

Mage::dispatchEvent('checkout_cart_update_item_complete',
array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);
if (!$this->_getSession()->getNoCartRedirect(true))
if (!$cart->getQuote()->getHasError())
$message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->escapeHtml($item->getProduct()->getName()));
$this->_getSession()->addSuccess($message);

$this->_goBack();

catch (Mage_Core_Exception $e)
if ($this->_getSession()->getUseNotice(true))
$this->_getSession()->addNotice($e->getMessage());
else
$messages = array_unique(explode("n", $e->getMessage()));
foreach ($messages as $message)
$this->_getSession()->addError($message);



$url = $this->_getSession()->getRedirectUrl(true);
if ($url)
$this->getResponse()->setRedirect($url);
else
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());

catch (Exception $e)
$this->_getSession()->addException($e, $this->__('Cannot update the item.'));
Mage::logException($e);
$this->_goBack();

$this->_redirect('*/*');



The call to $this->_goBack() in the end of the try-block seems to set the redirect URL correctly by looking at settings and a 'return_url' parameter (and I've verified that the code gets this far). But, as you can see, the last line always sets a redirect to */* no matter what. Just adding a return statement after the _goBack() call fixes the problem but I rather do this without modifying the core files.



Any ideas how I can solve this problem?










share|improve this question














bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

    – Julien Lachal
    Jul 23 '15 at 14:38

















3















I have a problem modifying a redirect in magento CE 1.9.2.



Let's say a customer has a configurable product in the cart, and would like to edit that product (ie. changing color or size or something).



After changing the options and clicking the 'update cart' button I want the customer to stay on the same page (ie. the edit product page). However magento always redirect back to the cart page.



I think I've found source of the problem, in CartController.php from the Checkout module:



/**
* Update product configuration for a cart item
*/
public function updateItemOptionsAction()

$cart = $this->_getCart();
$id = (int) $this->getRequest()->getParam('id');
$params = $this->getRequest()->getParams();

if (!isset($params['options']))
$params['options'] = array();

try
if (isset($params['qty']))
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
$params['qty'] = $filter->filter($params['qty']);


$quoteItem = $cart->getQuote()->getItemById($id);
if (!$quoteItem)
Mage::throwException($this->__('Quote item is not found.'));


$item = $cart->updateItem($id, new Varien_Object($params));
if (is_string($item))
Mage::throwException($item);

if ($item->getHasError())
Mage::throwException($item->getMessage());


$related = $this->getRequest()->getParam('related_product');
if (!empty($related))
$cart->addProductsByIds(explode(',', $related));


$cart->save();

$this->_getSession()->setCartWasUpdated(true);

Mage::dispatchEvent('checkout_cart_update_item_complete',
array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);
if (!$this->_getSession()->getNoCartRedirect(true))
if (!$cart->getQuote()->getHasError())
$message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->escapeHtml($item->getProduct()->getName()));
$this->_getSession()->addSuccess($message);

$this->_goBack();

catch (Mage_Core_Exception $e)
if ($this->_getSession()->getUseNotice(true))
$this->_getSession()->addNotice($e->getMessage());
else
$messages = array_unique(explode("n", $e->getMessage()));
foreach ($messages as $message)
$this->_getSession()->addError($message);



$url = $this->_getSession()->getRedirectUrl(true);
if ($url)
$this->getResponse()->setRedirect($url);
else
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());

catch (Exception $e)
$this->_getSession()->addException($e, $this->__('Cannot update the item.'));
Mage::logException($e);
$this->_goBack();

$this->_redirect('*/*');



The call to $this->_goBack() in the end of the try-block seems to set the redirect URL correctly by looking at settings and a 'return_url' parameter (and I've verified that the code gets this far). But, as you can see, the last line always sets a redirect to */* no matter what. Just adding a return statement after the _goBack() call fixes the problem but I rather do this without modifying the core files.



Any ideas how I can solve this problem?










share|improve this question














bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

    – Julien Lachal
    Jul 23 '15 at 14:38













3












3








3








I have a problem modifying a redirect in magento CE 1.9.2.



Let's say a customer has a configurable product in the cart, and would like to edit that product (ie. changing color or size or something).



After changing the options and clicking the 'update cart' button I want the customer to stay on the same page (ie. the edit product page). However magento always redirect back to the cart page.



I think I've found source of the problem, in CartController.php from the Checkout module:



/**
* Update product configuration for a cart item
*/
public function updateItemOptionsAction()

$cart = $this->_getCart();
$id = (int) $this->getRequest()->getParam('id');
$params = $this->getRequest()->getParams();

if (!isset($params['options']))
$params['options'] = array();

try
if (isset($params['qty']))
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
$params['qty'] = $filter->filter($params['qty']);


$quoteItem = $cart->getQuote()->getItemById($id);
if (!$quoteItem)
Mage::throwException($this->__('Quote item is not found.'));


$item = $cart->updateItem($id, new Varien_Object($params));
if (is_string($item))
Mage::throwException($item);

if ($item->getHasError())
Mage::throwException($item->getMessage());


$related = $this->getRequest()->getParam('related_product');
if (!empty($related))
$cart->addProductsByIds(explode(',', $related));


$cart->save();

$this->_getSession()->setCartWasUpdated(true);

Mage::dispatchEvent('checkout_cart_update_item_complete',
array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);
if (!$this->_getSession()->getNoCartRedirect(true))
if (!$cart->getQuote()->getHasError())
$message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->escapeHtml($item->getProduct()->getName()));
$this->_getSession()->addSuccess($message);

$this->_goBack();

catch (Mage_Core_Exception $e)
if ($this->_getSession()->getUseNotice(true))
$this->_getSession()->addNotice($e->getMessage());
else
$messages = array_unique(explode("n", $e->getMessage()));
foreach ($messages as $message)
$this->_getSession()->addError($message);



$url = $this->_getSession()->getRedirectUrl(true);
if ($url)
$this->getResponse()->setRedirect($url);
else
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());

catch (Exception $e)
$this->_getSession()->addException($e, $this->__('Cannot update the item.'));
Mage::logException($e);
$this->_goBack();

$this->_redirect('*/*');



The call to $this->_goBack() in the end of the try-block seems to set the redirect URL correctly by looking at settings and a 'return_url' parameter (and I've verified that the code gets this far). But, as you can see, the last line always sets a redirect to */* no matter what. Just adding a return statement after the _goBack() call fixes the problem but I rather do this without modifying the core files.



Any ideas how I can solve this problem?










share|improve this question














I have a problem modifying a redirect in magento CE 1.9.2.



Let's say a customer has a configurable product in the cart, and would like to edit that product (ie. changing color or size or something).



After changing the options and clicking the 'update cart' button I want the customer to stay on the same page (ie. the edit product page). However magento always redirect back to the cart page.



I think I've found source of the problem, in CartController.php from the Checkout module:



/**
* Update product configuration for a cart item
*/
public function updateItemOptionsAction()

$cart = $this->_getCart();
$id = (int) $this->getRequest()->getParam('id');
$params = $this->getRequest()->getParams();

if (!isset($params['options']))
$params['options'] = array();

try
if (isset($params['qty']))
$filter = new Zend_Filter_LocalizedToNormalized(
array('locale' => Mage::app()->getLocale()->getLocaleCode())
);
$params['qty'] = $filter->filter($params['qty']);


$quoteItem = $cart->getQuote()->getItemById($id);
if (!$quoteItem)
Mage::throwException($this->__('Quote item is not found.'));


$item = $cart->updateItem($id, new Varien_Object($params));
if (is_string($item))
Mage::throwException($item);

if ($item->getHasError())
Mage::throwException($item->getMessage());


$related = $this->getRequest()->getParam('related_product');
if (!empty($related))
$cart->addProductsByIds(explode(',', $related));


$cart->save();

$this->_getSession()->setCartWasUpdated(true);

Mage::dispatchEvent('checkout_cart_update_item_complete',
array('item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse())
);
if (!$this->_getSession()->getNoCartRedirect(true))
if (!$cart->getQuote()->getHasError())
$message = $this->__('%s was updated in your shopping cart.', Mage::helper('core')->escapeHtml($item->getProduct()->getName()));
$this->_getSession()->addSuccess($message);

$this->_goBack();

catch (Mage_Core_Exception $e)
if ($this->_getSession()->getUseNotice(true))
$this->_getSession()->addNotice($e->getMessage());
else
$messages = array_unique(explode("n", $e->getMessage()));
foreach ($messages as $message)
$this->_getSession()->addError($message);



$url = $this->_getSession()->getRedirectUrl(true);
if ($url)
$this->getResponse()->setRedirect($url);
else
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());

catch (Exception $e)
$this->_getSession()->addException($e, $this->__('Cannot update the item.'));
Mage::logException($e);
$this->_goBack();

$this->_redirect('*/*');



The call to $this->_goBack() in the end of the try-block seems to set the redirect URL correctly by looking at settings and a 'return_url' parameter (and I've verified that the code gets this far). But, as you can see, the last line always sets a redirect to */* no matter what. Just adding a return statement after the _goBack() call fixes the problem but I rather do this without modifying the core files.



Any ideas how I can solve this problem?







magento-1.9 cart redirect magento-ce






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 23 '15 at 14:15









Simon StrandmanSimon Strandman

162




162





bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 8 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

    – Julien Lachal
    Jul 23 '15 at 14:38

















  • You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

    – Julien Lachal
    Jul 23 '15 at 14:38
















You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

– Julien Lachal
Jul 23 '15 at 14:38





You could either override the CartController in a custom module, or find another way around. As far as I know, when you edit a configurable product, it should redirect you to the cart (default behavior) which seems logical because you wanted to change the option, not gaze at the product once more. Why would you want customers to stay on the edit page?

– Julien Lachal
Jul 23 '15 at 14:38










1 Answer
1






active

oldest

votes


















0














If you want the customer to say on the update page you could



  1. Use Ajax to post the changes to the server.


  2. Add a return_url parameter to your post action (with the current url see protected function _goBack())


  3. Change the global behavior for adding and updatig product in System -> Configuration -> Sales tab -> Checkout and then in the Shopping Cart tab you set the After Adding a Product Redirect to Shopping Cart


  4. Rewrite the controller using a custom module






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f75478%2fmodifying-the-redirect-after-editing-a-product-in-the-cart%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If you want the customer to say on the update page you could



    1. Use Ajax to post the changes to the server.


    2. Add a return_url parameter to your post action (with the current url see protected function _goBack())


    3. Change the global behavior for adding and updatig product in System -> Configuration -> Sales tab -> Checkout and then in the Shopping Cart tab you set the After Adding a Product Redirect to Shopping Cart


    4. Rewrite the controller using a custom module






    share|improve this answer



























      0














      If you want the customer to say on the update page you could



      1. Use Ajax to post the changes to the server.


      2. Add a return_url parameter to your post action (with the current url see protected function _goBack())


      3. Change the global behavior for adding and updatig product in System -> Configuration -> Sales tab -> Checkout and then in the Shopping Cart tab you set the After Adding a Product Redirect to Shopping Cart


      4. Rewrite the controller using a custom module






      share|improve this answer

























        0












        0








        0







        If you want the customer to say on the update page you could



        1. Use Ajax to post the changes to the server.


        2. Add a return_url parameter to your post action (with the current url see protected function _goBack())


        3. Change the global behavior for adding and updatig product in System -> Configuration -> Sales tab -> Checkout and then in the Shopping Cart tab you set the After Adding a Product Redirect to Shopping Cart


        4. Rewrite the controller using a custom module






        share|improve this answer













        If you want the customer to say on the update page you could



        1. Use Ajax to post the changes to the server.


        2. Add a return_url parameter to your post action (with the current url see protected function _goBack())


        3. Change the global behavior for adding and updatig product in System -> Configuration -> Sales tab -> Checkout and then in the Shopping Cart tab you set the After Adding a Product Redirect to Shopping Cart


        4. Rewrite the controller using a custom module







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 23 '15 at 14:41









        Renon StewartRenon Stewart

        12.2k12044




        12.2k12044



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f75478%2fmodifying-the-redirect-after-editing-a-product-in-the-cart%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

            Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

            How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2