WooCommerce Coupon Shortcodes

This extension for WooCommerce allows you to render coupon information and show content based on the validity of coupons. You can install WooCommerce Coupon Shortcodes directly from your WordPress Dashboard.

Customers can be motivated to proceed with their purchase, offering them to use specific coupons
when the contents in the cart qualify for it, or by offering them to purchase additional items
so they can use a coupon.

Extended coupon discount info for volume discounts can be shown when used with the Volume Discount Coupons extension.

This tools also works great when used with WooCommerce Group Coupons and WooCommerce Coupons Countdown.

Conditional Shortcodes

It provides the following conditional shortcodes that allow to enclose content which is shown if coupons are applied, valid or not valid.

  • [coupon_is_applied] and [coupon_is_not_applied]
  • [coupon_is_valid] and [coupon_is_not_valid]
  • [coupon_is_active] and [coupon_is_not_active]
  • [coupon_has_active] and [coupon_has_not_active]
  • [coupon_has_valid] and [coupon_has_not_valid]
  • [coupon_has_applied] and [coupon_has_not_applied]

Coupon Information

It also provides shortcodes that allow to render the coupon code, its description and an automatic description of the discount:

  • [coupon_show]
  • [coupon_code]
  • [coupon_description]
  • [coupon_discount]

Working with Sets of Coupons

A coupon iterator makes it easy to work with a set of coupons.

  • [coupon_iterate]

A coupon enumerator produces a list of coupon information.

  • [coupon_enumerate]

Documentation

The Documentation provides detailed descriptions and examples.


Comments

85 responses to “WooCommerce Coupon Shortcodes”

  1. Hi.

    I’m using coupons with usage limit per user and I’d like to display (preferably on “My Account” page) information about it. Something like: “You have used the coupon 5 out of 10 available time”

    Any chance I could sort this out with this module?

    Cheers!

    1. Hi Serban,

      Thanks for asking, unfortunately, this particular case you describe is not covered by the plugin.

      Cheers

  2. I have installed woocommerce plugin on my website. i was facing issue and i put above mentioned shortcodes to fix issues and i have succesfully fixed.

    1. Great, happy selling!

  3. The latest WooCommerce Coupon Shortcodes release 1.23.0 is out and the information on this page has been updated to reflect the latest additions.

  4. Hello! I’m trying to understand this. I have multiple codes generated and I want it to show only one but not random. Just in order with no repetition. So when I a person enters the website the shortcode should read the multiple codes on woocommerce and show it in order and not random. is it possible?

    1. The code I’m using is this one: [coupon_enumerate code="*" orderby="rand" number="1" type="percent" prefix="bsf"]
      [coupon_code prefix="bsf_"]

      Prefix isn’t working I have other coupons created that no has that prefix and it is show also.

      1. Hi Juan,

        You are indicating orderby=”rand” which will provide you with a random code from those eligible. As you mentioned ” I want it to show only one but not random. Just in order with no repetition.” this is not what you want but you should rather use orderby=”code” or not indicate that attribute at all as that is the default. You’re also missing the closing tag and mixing up some attributes. This would do what you describe:

        [coupon_enumerate code="*" number="1" type="percent"]
        [coupon_discount prefix="code"]
        [/coupon_enumerate]

        Note that you’re only showing the first one of those eligible as you’re using the number attribute. Remove that to show all or adjust as needed.

        Documentation Reference: http://docs.itthinx.com/document/woocommerce-coupon-shortcodes

        Cheers

  5. This shortcode is not functioning properly in the latest woocommerce release: coupon_is_not_valid.
    A coupon has been set to exclude a certain category.
    But when visiting the product tied to that category, it says the coupon is valid.

    1. Hi,

      This shortcode would reveal the content it surrounds when the coupon is not considered valid. If you have excluded a product category in a coupon, then the coupon would not be valid if any product is in the cart that belongs to that category. In that case, you would see the content of the shortcode revealed. Otherwise, if you have no products in the cart or only products that do not belong to the excluded category, the coupon would be valid and the contents of the shortcode would not be displayed.

      > But when visiting the product tied to that category, it says the coupon is valid.

      It seems that you are mistaking validity features with what this extension does, I would suggest that you review your settings used on the coupon.

      Cheers

  6. Are there any hooks? I need to override “description”.
    [coupon_show show="description"]

    It’s currently stripping out HTML and I need it to show HTML.

    1. Hi Jason,

      Currently there are no filters you could use to override that, but it would certainly be useful. I’ll add it as a suggested improvement which we could provide in an update.

      Cheers

  7. I would like the plugin to display a coupon on the product page, if it is relevant to that product page. The coupon would be an image with a click to apply link. I can imagine it looking like this:

    [coupon_enumerate code="*" orderby="rand" number="1"]
    [coupon_show show="image"]
    [/coupon_enumerate]

    I may be able to add an image field to coupons. Is there a way to add the additional “image” attribute to “coupon_show”? I see in other places you have:
    [coupon_show show="code,description,discount"]
    But I’d need to use “image”.

    1. Hi Jason,

      Nice idea, but not something you could achieve with the extension without coding it, or by using a conditional shortcode that wraps the image to display:

      [coupon_is_active code="test"]
      (your image here)
      [/coupon_is_active]

      Please have a look here http://docs.itthinx.com/document/woocommerce-coupon-shortcodes for details on that shortcode. If that doesn’t work out for your case, then you’d really have to come up with an implementation of your own 🙂

      Cheers

      1. Thanks for you response. I would need it to be dynamic, so iterating through and selecting the appropriate coupons for the product page would be best. So I might reach out at some point. Thanks.

  8. I would like the coupon description to display in the Cart Totals after a coupon is entered, not just when it’s set to automatically apply a coupon. How can I achieve this?

    1. Hi Diane,

      There is an example on http://docs.itthinx.com/document/woocommerce-coupon-shortcodes/ (look for Example for Scenario B: on the page) where the discount info is rendered using a combination of shortcodes. This can also be used with the shortcode that renders the description. You can add that to the cart page but keep in mind that if the cart content is updated dynamically using Ajax, that wouldn’t be updated unless you revisit the page. Alternatively, you can modify the cart template, in that case I guess it would also include the updated information that is included with the shortcodes.

      Cheers

  9. Mayank Gupta Avatar
    Mayank Gupta

    I have different coupons that are eligible for different products. Is there a shortcode that I could add on the single product page that would only display coupons that are eligible for that particular product instead of adding different coupons in each product page?

    1. Hi,

      That isn’t possible with this extension but you could have a look at our WooCommerce Volume Discount Coupons which offers display options documented here that allow to display discount information relevant to products.

      Cheers

  10. Where should I place these short codes?

    1. Anywhere on a page etc, see https://codex.wordpress.org/Shortcode for an introduction on how shortcodes are used.

  11. umapriya Avatar

    Hi,
    I want to display ONLY all VALID coupons. Pls help to modify below code.

    [coupon_enumerate code="*" type="subscription,percent"]
    [coupon_description element_tag="div" prefix="code"]
    [/coupon_enumerate]

    1. Hi,

      You can use the [coupon_is_valid] shortcode for that. Details can be found on http://docs.itthinx.com/document/woocommerce-coupon-shortcodes/

      Cheers

  12. can you provide any video tutorial on how to use this plugin?
    (for non techie)

    1. Hi,

      We have the documentation for this extension here where you will find details on how to use it. It’s pretty easy to use by following the examples outlined there – you can copy and paste them easily and adjust them to the coupon codes you are using.

      Cheers!

      1. Can you share how to combine the enumerate and coupon is valid? I cannot get it to work.

        1. Hi Hunter,

          I’d need to see what you were trying to do, but if you tried to combine the [coupon_enumerate] enclosing [coupon_is_valid] then that wouldn’t produce anything – these are not designed to work together that way. What are you trying to achieve?

          Cheers

          1. That is exactly why I was doing.

            [coupon_enumerate code="*"]
            [coupon_is_valid]
            [coupon_discount element_tag="div" prefix="code"]
            [/coupon_enumerate]

            I would like to be able to show all coupons that are valid instead of having to type out each shortcode.

            1. Hi Hunter,

              Ok, this won’t work as I explained before. But it might be interesting to allow to specify that you only want to include coupons that are currently valid based on the current cart contents to be included when rendering with [coupon_enumerate code="*"] – I’m thinking of allowing to specify an additional attribute, something like [coupon_enumerate code="*" valid="yes"] … I’ll check it, it certainly sounds useful.

              Cheers

              1. Hello! I’m looking to do something similar to this with showing active coupons. I’m attempting this code but its not working
                [coupon_is_active][coupon_enumerate code="*"][coupon_description] // Use code [coupon_code][/coupon_enumerate][/coupon_is_active]

                Alternatively, is there another way to show non-expired coupons??

                1. Hi Teri,

                  Thanks for asking! We’re working on an update of the extension. Let me check if that’s a possible addition to the new release and get back to you.

                  Cheers

                2. FYI We’ve just released an update and have added a new shortcode [coupon_iterate] – please make sure to review the documentation page for examples: https://docs.itthinx.com/document/woocommerce-coupon-shortcodes/

                  It includes the case you have been asking for. Thanks for the suggestion, this was very useful! Hope you like it 🙂

                  1. This is great, thank you!
                    Another question – is there a way to show all active coupons, with the exception of some (specific for influencers, etc…)?

                    1. You’re welcome, this was good to add!

                      For coupons that are limited to specific user groups, I would recommend to use the premium extension Group Coupons extension. This would allow you to limit coupons to certain groups, e.g. you could create an Influencer group for coupons that could only be applied by member accounts. Then you could do this:

                      [coupon_iterate code="*"]
                      [coupon_is_active]
                      [coupon_is_valid]
                      [coupon_code] ...
                      [/coupon_is_valid]
                      [/coupon_is_active]
                      [/coupon_iterate]

                      This would only show coupons that are active and also valid for who is viewing them. With the validity restrictions imposed by the Group Coupons extension, it would only include the coupons that are valid for influencers if they belong to the Influencers group.

                      I think there is another opportunity for improvement on the WooCommerce Coupon Shortcodes plugin, so that restrictive filters such as those imposed by Groups itself on the coupon post type could be taken into account. But this will take some thought and testing which we can’t schedule right now because of other priorities. I’ll take note of it though, to revise it and make the necessary additions as soon as possible. If you think that the solution that I’ve outlined above is an option, then that’s something you could use right now.

                      Cheers

  13. Hi, i want to show, how many coupons has been used and how many left.

    Is it possible using this plugin?

    1. Hi Ilkar,

      Thanks for asking, sorry but this isn’t possible with this extension.

      Cheers

  14. Hi,

    Shortcode doesn’t show until product is added to the cart. I entered the shortcode in the product description and would like coupon text to show up if coupon is valid for the product being viewed.
    I am using the [coupon_is_valid] shortcode. How can I make the shortcode active on the product page before product is in the cart

    [coupon_is_valid code="Q2 Prorated"]AED 2,756.25 Current Q2 Prorated Price
    Subscriptions purchased after 1st of April are prorated.
    Discount will automatically apply at checkout.
    [/coupon_is_valid]

    Please advise…

    1. Hi Hasan,

      I suppose that the coupon you use is conditionally valid based on the cart contents. The shortcode is only supposed to show the information when the coupon code is valid at the time the shortcode is evaluated. If you would like to show it when the code is not valid, then you can use [coupon_is_not_valid] instead.

      Cheers

  15. Dear developer,

    I am not familiar with this. Our site is using AffiliateWP for all affiliates. For some affiliates, they have a discount but for others they do not. We create coupons to apply those discounts. For those who do not have, an error message of “Coupon code does not exist!” will appear. I am trying to use this plugin to override this error message. But that does not work. Any suggestions?

    Thank you!

    1. antonio Avatar

      Hi Bertie,
      This plugin doesn’t change the coupon messages. With this plugin you have available a lot of shortcode that you can use related with coupons.Please have a look at the documentation page.
      Maybe are you talking about Woocommerce Coupon Messages ?
      Kind Regards,
      Antonio B.

  16. Hi Antonio

    When I disable the plugin, the hidden text becomes visible. The standard “Coupon code applied successfully.” comes up fine. When I enable the plugin, the text is hidden again and once more, the standard “Coupon code applied successfully.” is displayed rather than the hidden message.

    I hope it is not a theme issue as it is the basic storefront theme sitting on the woo commerce plugin on WordPress. All items fully updated now to WordPress 4.7, WooCommerce 2.6.9 and Storefront Theme 2.1.6.

    1. Mmmm,
      please enable the plugin, give me the url and a coupon to apply (if you want you can send me an email to antonio[at]itthinx[dot]com with this info, indicating this conversation).
      Kind Regards,
      Antonio B.

  17. Kento

    I am trying to get a message displayed to thank purchasers for using the coupon which then issues a donation to a charity.

    The code does work but only when I refresh the page AFTER the code has been applied. So if in the cart page I apply the code, no message appears but if I then refresh the page it does appear. The same thing happens on the checkout page.

    At the moment I have it set on the checkout page in the hope that the coupon is used on the cart page. When that is done and the customer moves to the checkout page the message displays correctly. However, if the coupon is then removed, the message once more remains until the page is refreshed.

    It seems that the code is not recognising that the coupon has been added and the page refreshed (the “Coupon code applied successfully.” banner comes up but not the short code message).

    It does say that the plugin has not been tested with my version ) WordPress 4.5.3, WooCommerce 2.6.2 and Storefront Theme 2.0.5

    Any guidance appreciated.

    1. Hi GeoffatMM,
      please try to disable the plugin and check if when you set a coupon in the cart page, the default message “Coupon code applied successfully.” appears. Maybe it’s theme problem.
      Kind Regards,
      Antonio B.

  18. James Rivas Avatar
    James Rivas

    Hello,

    I don’t know how often this happens but I installed the plug in to the my site and then I refreshed the page and I got this in return:

    Fatal error: Access level to SYN_Shipping_Method::get_field_default() must be public (as in class WC_Settings_API) in /home/raulme5/public_html/(myusername)/wp-content/plugins/synmedia-woocommerce-shipping-ups/syn-shipping/class-syn-shipping-method.php on line 707

    That is all the is showing up.
    I can’t log into my page any more or see it for that matter.

    I want to know how I can undo the installation or what I can do to fix the problem.

    1. Hi James,
      This seems a problem with the synmedia-woocommerce-shipping-ups (maybe you have a low memory limit, you can check this from Woocommerce->System Status).
      To disable the plugin, you could access using the FTP, and delete the plugin folder. Then you should can access.
      Kind Regards,
      Antonio B.

  19. Im really not trying to be stupid…but I am trying to add “[coupon_description] where do I input the shortcode….the cart page? I added a coupon and already made a description. please help

    1. Hi EA,
      really you can set the shortcode in posts/pages or using do_shortcode you can set the shortcode in your theme code.
      Maybe the documentation page can help you.
      Kind Regards,
      Antonio B.

  20. Hello,
    I’m trying to use this plugin with “do_shortcode” function but it doesn’t work .
    seems like it doesn’t work also when I’m using it in a regular post or page with WordPress editor
    Do you know what could be the problem?

    1. Hi Aharon,
      the ‘do_shortcode’ function is used in PHP code. If you need to use the shortcodes from the WordPress editor, simply write them, ex.
      [coupon_is_valid code="superdiscount"]
      You qualify for a discount!
      Use the coupon code [coupon_code] to take advantage of this great discount : [coupon_discount]
      [/coupon_is_valid]

      Please be sure that you are in the ‘Text’ tab in the editor.
      Kind Regards,
      Antonio B.

  21. Does not show coupons on the top page until opening the cart page.
    Once the cart page was opened, coupons can be displayed on the top page.
    Any ideas?

    My code:

    <?php
    $coupon_id = array('abc','def');
    foreach($coupon_id as $id){
    echo do_shortcode('
    [coupon_is_valid code="'.$id.'"]
    [coupon_code code="'.$id.'"]
    [coupon_description code="'.$id.'"]
    [/coupon_is_valid]
    [coupon_is_not_valid code="'.$id.'"]
    No coupons available now.
    [/coupon_is_not_valid]
    ');
    }
    ?>

    1. Hi,

      This would be because the coupons aren’t valid unless there is something in the cart they can be applied to. Does that make sense in the test scenario you have been trying?

      Cheers

      1. Thanks.

        In my scenario, I would like to show all the coupons that useable to users, before anything added to the cart.
        I have a showcase for these coupons.

        Is this doable?

        Thanks again.

        1. Hi,

          If you don’t want to make it dependent on whether the coupons are valid at the time they should be displayed, then you could simply remove the [coupon_is_valid] shortcodes wrapping the display shortcodes. But maybe in your case it would be simpler to just show the coupon codes that are available without using any shortcodes at all?

          Cheers

  22. Hi Antonio

    I’m having difficulty displaying coupons via your shortcodes on cart page.

    for example:

    [coupon_is_valid code="456000"]
    We’ve got a discount for this product, yay! Use the coupon:
    [coupon_discount element_tag="div" prefix="code" prefix_separator=": "]
    [/coupon_is_valid]

    displays the coupon when the associated product is in the cart, great. But it only works for that specific coupon number.
    What if i have a lot of coupons for all variable products and need to display available coupon that’s tied in with the products in the cart? basically do the above but include all the available coupons.
    Because replacing the coupon code number with ( * ) doesn’t do anything.

    Any thoughts?

    1. antonio Avatar

      Hi Alexey,
      you can use coupons separated by commas, but you need to set every coupon.
      It seems an interesting option, we will review this.
      Kind Regards,
      Atonio B.

  23. valid short code not working

    1. antonio Avatar

      Hi anu,
      exactly what shortcode are you using?
      Kind Regards,
      Antonio B.

  24. Hello, I’ve opened a thread. I thought I’d post here in case you don’t get notified.
    https://wordpress.org/support/topic/excluding-private-coupons

    1. antonio Avatar
      antonio

      Hi Tushar,
      you could use the ‘element_tag’ attribute on the coupon_description and coupon_discount shortcodes (sorry, coupon_code hasn’t this attribute). Maybe if you play with the ‘coupon’ span class you can get what you want.
      Kind Regards,
      Antonio B.

  25. Orlando Avatar
    Orlando

    Hello, is there any way to show the number of coupons left? eg: I’ve got a promotion going for a few days where users who use a coupon get a special item as a gift, but I limited the coupons to 10 units. Is there any way to get the number of coupons left?

    Thanks!

    1. antonio Avatar
      antonio

      Ho Orlando,
      Sorry, right now this option is not available.
      Kind Regards,
      Antonio B.

  26. Sorry for the basic question – how do I add the shortcode to the checkout page? Do I edit the form-coupon.php, & will this get overwritten if Woocommerce upgrades?

    1. Hi Steve,
      If you need to override the checkout page, this post can help you.
      With do_shortcode you can add shortcode in your php files.
      Maybe you don’t need to modify the php file, and you can use the filters. This post can help you.
      Kind Regards,
      Antonio B.

  27. Is it possible to filter the Registered users by ID and show them coupons assgned to them

    1. Hi Denislav, currently not, see the documentation for details on the current capabilities please.

  28. I is there a way to create a list of all coupons that gives

    the code(in bold)and the description

    Currently I’m using enumerate but it’s spaced and I want to add to wording in between.

    1. Hi Bernice, here’s an example:

      <div class="the-coupons">
      [coupon_enumerate code="*" type="subscription,percent"]
      [coupon_description element_tag="div" prefix="code"]
      [/coupon_enumerate]
      </div>

      <style type="text/css">
      .the-coupons .coupon.code {
      font-weight: bold;
      }
      </style>

      1. Perfect…. I even added color to the style type area. Thanks!

  29. Hi,

    its just to translate it into french. What file should I add to the folder ?

    Thanks 🙂

    1. Hi James, would you like to contribute your translation? It would have to be added to the lib/languages folder inside the plugin.

  30. Hi !
    Thanks for the plugin !
    How can I translate or change the text “Discount” ?

    Thanks 🙂

    James

    1. Hi James,

      You would place your translation files in the plugin’s lib/languages folder, or do you need a filter that hasn’t been added yet?

  31. Brad Ungar Avatar
    Brad Ungar

    Been trying to use the “enumerate” short code to list all of our current coupons on a page, but they are not showing anything. I have coupons created and using the code:

    [coupon_enumerate code="*" type="percent"]
    [coupon_discount element_tag="div" prefix="code"]
    [/coupon_enumerate]

    Thanks!

    1. Can we have a look at how you have the coupons set up on the admin side? You can provide access to support at itthinx dot com.

  32. Hi,
    I’d like to be able to display a voucher box in the Admin Order screen and then input a coupon if needed. Otherwise just display the on-line order coupon if there is one.
    Is that possible?
    Thanks
    Guy

    1. Hi,
      you can use Meta box plugin to add metaboxes. To create your personal metabox, this post can help you (you must use ‘shop_order’ on ‘pages’ atribute to show the metabox on Woocommerce order).
      cheers

  33. Hi Kento
    Thanks for Sunday feedback ;-).
    From the documentation I understood that[coupon_code] etc can be used on their own as well.
    However, on my (test-)page I use [coupon_code] directly followed by [group_coupons]. The last one shows correctly the valid coupon while [coupon_code] brings the Warning.
    That’s why I believe there is somehing else wrong.
    Thank you and best regards,
    Frank

    1. Hi Frank, I assume with the update released this now works for you as expected. Please let me know if not. Cheers

      1. Hi Kento

        Yes, I don’t see the warning message anymore.

        But in my implementation I don’t see [coupon_code] displaying anything:
        I use the plugin group-coupons to automatically appoint a coupon to group members and a certain product. By doing this I have a discount for already subscribers to modivate them to subscribe for a 2nd product.

        On top of my checkout page I can see the coupons with
        [group_coupons auto="yes" groups="yes" show_cart_invalid="false" show_discount="yes"]

        But next to it I have no display of the same coupons using [coupon_code]

        I would prefer using [coupon_code] because it gives me more flexibility. However, in my case it doesn’t display anything.

        I hope I could explain this scenario well enough. Let me know if you need more background.

        Thanks and best regards,
        Frank

        1. Hey Frank,

          What you describe sounds ok, but are you supplying any codes to the [coupon_code] shortcode? The way [group_coupons] works is different from [coupon_code], as the latter needs to be fed coupon codes, either by attribute or by using surrounding shortcodes.

          I think you’re basically looking for this:

          [coupon_is_applied]
          [coupon_description]
          [/coupon_is_applied]

          You can fine-tune that, see http://www.itthinx.com/documentation/woocommerce-coupon-shortcodes/

          Cheers

  34. Hi Kento

    I tried out WooCommerce Coupon Shortcodes because I like the conditional display of coupons.
    I tried out very simple with [coupon_code],[coupon_description] and [coupon_discount].
    But I get following error message:
    “Warning: Invalid argument supplied for foreach() in /home/…/wp-content/plugins/woocommerce-coupon-shortcodes/lib/views/class-woocommerce-coupon-shortcodes-views.php on line 655” for [coupon_discount].
    ” … line 529″ for [coupon_code] and ” … line 580″ for [coupon_description].

    Other Plugins I’m using (just listed the ones i believe are involved; all on latest release):
    – Groups
    – Groups Woocommerce
    – WooCommerce
    – WooCommerce Deutsch (de_DE)
    – WooCommerce Coupon Shortcodes
    – WooCommerce Group Coupons
    – WooCommerce Multilingual
    – WooCommerce PDF Invoices
    – WooCommerce Subscriptions

    Is the problem related to fact that I’m using Coupons together with subscriptions?

    Thank you for your help and best regards,
    Frank

    1. Thanks for pointing that out Frank, the Warning is displayed because the shortcode expects at least one code to be passed. See the documentation for details on how to supply the codes so that the shortcodes can display coupon info appropriately.

      The thing with the Warning issued should be fixed though.

  35. Hi,
    We do a lot of offline orders when customers telephone us with their order and we use the woocommerce Admin Order page.
    Can you help me as we want to be able to enter coupon codes on the Admin Order screen?

    Kind regards Guy

    1. Hi,

      It depends on what you want to achieve, how do you want to use the shortcodes that the plugin provides in relation to the manual process?

Leave a Reply

Your email address will not be published. Required fields are marked *

Share