What I would like to do is add a product and a coupon to the cart at the same time from a product page.

The reasoning behind this is we are creating a landing page for a specific coupon and want to add both the product and coupon to the cart with only a single click for the user.

  • How to extend the functionality of this snippet to apply coupon when two products (different IDs) are in the cart? Coupondunia Jan 3, 2019 at 6:58
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review Jan 3, 2019 at 7:25

3 Answers 3


Hi Have you tried event checkout_cart_add_product_complete and This event is sending params product cart params and product object to Observer

array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())

That using this event you can add your coupon code

If you want apply coupon from product page then create a input on product page or product add to cart url and send (coupon_code=yourcouponCode).

then you get coupon code at observer using $oberver->getEvent()->getRequest()->getParam('coupon_code')

  • you are welcome @DavidManners
    – Amit Bera
    Nov 12, 2014 at 9:54

You could customize your add to cart button to use the querystring method

See magento: URL querystring for adding product and applying discount coupon to cart


return_url - need to be encoded

See /app/code/core/Mage/Checkout/controllers/CartController.php

 * Set back redirect url to response
 * @return Mage_Checkout_CartController
protected function _goBack()
    $returnUrl = $this->getRequest()->getParam('return_url');
    if ($returnUrl) {

        if (!$this->_isUrlInternal($returnUrl)) {
            throw new Mage_Exception('External urls redirect to "' . $returnUrl . '" denied!');

    } elseif (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
        && !$this->getRequest()->getParam('in_cart')
        && $backUrl = $this->_getRefererUrl()

Another approach is to look at the SalguaMagentoAddProduct extension https://github.com/salgua/SalguaMagentoAddProduct it provides the ability to do what you are looking for.

Your Answer

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

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