tags:

views:

24

answers:

1

Hi!

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?

Thanks,
Joe

+1  A: 

You could create an observer listening for the checkout_cart_add_product_complete event and in there you could do something like the following

  public function addToCartComplete(Varien_Event_Observer $observer) {
    // Send the user to the Item added page
    $response = $observer->getResponse();
    $request = $observer->getRequest();
    $response->setRedirect(Mage::getUrl('checkout/onepage'));
    Mage::getSingleton('checkout/session')->setNoCartRedirect(true);
}

Your config would look something like this

 <frontend>
    <events>
    <checkout_cart_add_product_complete>
      <observers>
        <packagename_modulename_observer>
          <type>singleton</type>
          <class>packagename_modulename/observer</class>
          <method>addToCartComplete</method>
        </packagename_modulename_observer>
      </observers>
      </checkout_cart_add_product_complete>
   </events>
   </frontend>
dan.codes