Redirect Magento to checkout onepage after adding item to cart

前端 未结 2 879
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 10:30

How can I redirect the user after it adds one item to the cart?
lets say I want him to choose one item and go to the checkout/onepage, how can I do that?

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-03 10:52

    Using checkout_cart_add_product_complete you will miss out on product addtocart success message check this

    Mage::dispatchEvent('checkout_cart_add_product_complete',
                        array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
                    );
    
    if (!$this->_getSession()->getNoCartRedirect(true)) {
     if (!$cart->getQuote()->getHasError()) {
             $message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->escapeHtml($product->getName()));
                   $this->_getSession()->addSuccess($message);
         }
           $this->_goBack();
    }
    

    Again if you don't wont the session messages, just pass additional parameter from your product page

    
    

    No need for any other customization or module creation, its magento's default functionality

提交回复
热议问题