I would like to create URLs which activate a specific coupon. It could be as simple as passing the coupon code as a URL parameter. When a coupon is passed, I'd like it to automatically be populated at time of checkout.

Is there a way to capture a coupon parameter into the session to automatically be applied to the cart?

  • I've used parts of the code of this free module to achieve this: magentocommerce.com/magento-connect/…
    – 7ochem
    Apr 17, 2015 at 19:26
  • Copy functionality of creation coupons from magento and put it to your own controller. If you want to use some strange urls - create also your own FRONT controller
    – zhartaunik
    Apr 18, 2015 at 21:40
  • I am currently working for a company that is doing a security analysis on coupon codes, links etc. You should make sure that you encrypt or disguise the coupon code in some way and force the user to login from the link. This is to prevent people who have had their emails hijacked or the like from being able to fraudulently claim coupons.
    – Joshua
    Jun 23, 2015 at 6:32
  • There’s an extension called Sticky Coupon that accomplishes just this. !automated coupon code populated field by using the sticky coupon extension
    – MrSkAppMan
    Dec 21, 2018 at 12:51
  • please add more details related to question and how it can help to sort out issue
    – Jarnail S
    Dec 21, 2018 at 13:40

2 Answers 2


You can use just the Magento core URL for coupon posting: http://example.com/checkout/cart/couponPost/coupon_code/MY_COUPON_CODE You can also add on ?return_url=http... if you want a specific return url or let it just redirect to the cart by default.

  • I'll play with that, and maybe I can use an .htaccess redirect to provide a simple URL that hides the cart details.
    – MarkE
    Aug 20, 2015 at 16:51
  • 3
    FYI googlers, this is an old answer with no version tags. I tested and this applies to Magento 2 (tested in 2.1.7 CE w/ sample data)
    – jamil
    Jul 19, 2017 at 18:28
  • Mind that this only works if you already have something in your cart.
    – Simon
    Apr 12, 2018 at 10:18
  • For me, Since I have items in cart, this is not working in magento 2.3.0. Any idea?
    – Pribhav
    Jun 28, 2019 at 9:26
  • 3
    @Pribhav In magento 2, they've changed the controller action that it must be a POST request. See here: github.com/magento/magento2/blob/2.3-develop/app/code/Magento/… That's why it doesn't work. You can create a custom controller, and then use that. Basically just copy the content of CouponPost into your controller and make your controller implement the Magento\Framework\App\Action\HttpGetActionInterface Jul 2, 2019 at 17:45

I wrote something that's free and open source which does exactly what you need and doesn't require items to already be in the cart. You can find it here: https://github.com/crankycyclops/DiscountCodeUrl

It's still pretty new and needs more testing (if you want to help me out, I'd really appreciate it!), but it's working well for me so far.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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