Generate Commerce Coupon and put the code in the email

Created on 24 June 2025, 4 months ago

I've implemented a patch for the 2.0 version (which I believe could be easily adapted to the 2.1 branch) to generate a Commerce coupon code and include it in the email.

More specifically, the patch adds an option to the module settings form to enable the feature and select which promotion the coupon code should be associated with.

Currently many coupon options are hardcoded but this could be extended in the future.

Do you think this would be a useful feature for the module? If you're interested, I can prepare a publishable patch for the 2.0 or 2.1 release. Let me know.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇮🇹Italy finex

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @finex
  • 🇺🇸United States scottsawyer Atlanta

    I am totally interested in this feature, whether or not it becomes part of the module. A customer just asked about this today. Please upload your patch!

  • 🇮🇹Italy finex

    Hi, this is the patch I'm using. It has some hardcoded settings but they works for me. Feel free to use and adapt for your needs.

  • 🇮🇹Italy finex

    I forgot to mention that I added a copy of commerce-abandoned-carts-email.html.twig to the theme and updated the markup by adding the {{ coupon_code }} Twig variable to output the generated coupon code.

Production build 0.71.5 2024