6

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 '15 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 '15 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 '15 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 – Magento Developer Dec 21 '18 at 12:51
  • please add more details related to question and how it can help to sort out issue – Jai Dec 21 '18 at 13:40
4

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 '15 at 16:51
  • 2
    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 '17 at 18:28
  • Mind that this only works if you already have something in your cart. – Simon Apr 12 '18 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 at 9:26
  • 1
    @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 – Moshe Brodsky Jul 2 at 17:45

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.