Magic Coupon for WooCommerce


With this plugin, you can pass a coupon code via an URL parameter (mcoupon by default) and it will be stored in a cookie for a configurable amount of time.

While the cookie is valid:

  • All the eligible products will have their display price reflect the coupon discount;
  • A personalized HTML message can be shown on the product page, under the product price (or anywhere else, if you know your way around hooks);
  • When the client adds the product to the cart, the coupon is automatically applied also;

Please note that the coupon can still be applied manually by the user at any time. This will not lock the coupon regular usage.


  • Magic coupon settings


  • Use the included automatic install feature on your WordPress admin panel and search for “Magic Coupon WooCommerce”;
  • On each coupon you want to activate this plugin features, you must go to the “Magic Coupon” tab and check “Enable”;


Can I change the URL parameter name from `mcoupon` to something else?

Yes. Use the magic_coupon_url_parameter filter.

Can I show the HTML message somewhere else on the product page?

Sure you can. Use the magic_coupon_html_message_action_hook filter to change the hook and the magic_coupon_html_message_action_priority filter to change the priority.

If you don’t know what we’re talking about, you should probably stop now and hire us to do it for you 🙂

Is it possible to add dynamic information to the HTML message?

You bet! Use one of the following placeholders on your message:

  • {product_id} will be replaced by the Product ID;
  • {coupon} will be replaced by the coupon code;
  • {cookie_expire_timestamp} will be replaced by the cookie expiration Unix timestamp;
  • {cookie_validity_minutes} will be replaced by the cookie validity in minutes;

You can also add you own placeholders with the magic_coupon_html_message_replace_tags filter. See an example here.

And because you can also use shortcodes on the HTML message field, you can feed the product id, coupon, the cookie expire timestamp or validity, or any other variable you set via your own placeholders as a shortcode argument, you can do whatever you want with your custom message. Go crazy, or hire us to develop a custom solution for you.

Can this plugin have issues with caching plugins?

Yes and no. The page output has to be changed to set the discounted product prices based on the user cookie. That’s incompatible with a server-side caching system unless your caching plugin has a way of disabling cache conditionally.

We set the following constants to prevent caching by some plugins:


This is exactly what WooCommerce does for the Cart, Checkout and My Account pages. So if your caching plugin can correctly show this pages without caching, you’re good to go with this plugin also. While our cookie is valid we’ll disable cache for that user on the whole website, because a product price can be shown anywhere (via a shortcode, for example).

Contributors & Developers

“Magic Coupon for WooCommerce” is open source software. The following people have contributed to this plugin.


“Magic Coupon for WooCommerce” has been translated into 1 locale. Thank you to the translators for their contributions.

Translate “Magic Coupon for WooCommerce” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Change log


  • Tested with WordPress 5.2.5-alpha and WooCommerce 3.8.0


  • Small readme.txt fixes