I'm using Magento 1.92. I want two buttons on product page,one is the default "add to cart"buttons;the other button,"proceed to checkout",Redirect to checkout after adding item to cart.
public function afterAddToCart(Varien_Event_Observer $observer) {
$response = $observer->getResponse();
$response->setRedirect(Mage::getUrl('checkout/onepage'));
Mage::getSingleton('checkout/session')->setNoCartRedirect(true);
}
use the Observer above and it can direct to checkout page.But I also want to keep the default add to cart button,so the code is:
public function afterAddToCart(Varien_Event_Observer $observer) {
if (Mage::app()->getRequest()->getParam(‘checkout’)) {
$response = $observer->getResponse();
$response->setRedirect(Mage::getUrl(‘checkout/onepage’));
Mage::getSingleton(‘checkout/session’)->setNoCartRedirect(true);
}
}
the button with "checkout" in the url direct to checkout page,the button without "checkout" in the url add product to cart. I'm stuck here.how to get the url of "add to cart" button?what if the product has custom options?