2

I need to change the default action after adding item to cart from wishlist. By default when you hit "Add to basket" button you will be redirected to the cart. I want user to be redirected back to wishlist.

I also know that going to Admin > System > Configuration > Default Config > Sales > Checkout > Shopping Cart > “After adding a product redirect to shopping cart”: Yes or No fixes my problem but I want to be able to do this only for wishlist and not globally, for one store only!

1 Answer 1

3

You can write an observer listen to the post_dispatch event

'controller_action_postdispatch_wishlist_index_cart'

and change the response to a redirect to the wishlist.

So create a new module/extension and add the following to your config.xml:

<global>
    ...
    <events>
        ...
        <controller_action_postdispatch_wishlist_index_cart>
            <observers>
                <yourcompany_yourmodule>
                    <type>singleton</type>
                    <class>YourCompany_YourModule_Model_Observer</class>
                    <method>controllerActionPostdispatchWishlistIndexCart</method>
                </yourcompany_yourmodule>
            </observers>
        </controller_action_postdispatch_wishlist_index_cart>
    </events>
</global>

Then in your Observer.php add the following method:

public function controllerActionPostdispatchWishlistIndexCart()
{
    Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::app()->getRequest()->getServer('HTTP_REFERER'));
}

That's it. Every time you will try to add something from your wishlist to your cart you will be redirected back to wishlist.

1
  • "a bit more detailed instructions." @Tim aahh yes :-) Thanks! Feb 27, 2013 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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