WooCommerce Coupon Shortcodes

Download

Download the free WooCommerce Coupon Shortcodes plugin for WordPress.

This extension for WooCommerce allows you to render coupon information and show content based on the validity of coupons.

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.

Coupon discount info for volume discounts can also be shown if the WooCommerce Volume Discount Coupons is installed.

Conditional Shortcodes

It provides the conditional shortcodes [coupon_is_applied], [coupon_is_valid] and [coupon_is_not_valid] that allow to enclose content which is shown if the coupon is (or is not) valid.

Coupon Info Shortcodes

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

[coupon_code]

(this one makes sense mostly when used inside one of the conditional shortcodes).

[coupon_description]
[coupon_discount]

Examples

Showing a coupon when the cart contents qualify for a coupon to be applied:

[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]

Showing a coupon that is not valid for the current cart and motivating to add items:

[coupon_is_not_valid code="25off"]
If you purchase 5 Widgets, you can use the coupon [coupon_code] to get 25% off your purchase!
[/coupon_is_not_valid]

Documentation and Support

Full usage instructions can be found on the Documentation page.

For support questions please use the form below to post a comment.

47 Responses to WooCommerce Coupon Shortcodes

  1. Guy November 18, 2013 at 10:06 am #

    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

    • kento November 18, 2013 at 6:11 pm #

      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?

  2. Frank November 23, 2013 at 12:29 pm #

    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

    • kento November 24, 2013 at 2:49 pm #

      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.

  3. Frank November 24, 2013 at 4:35 pm #

    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

    • kento December 2, 2013 at 9:29 pm #

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

      • Frank December 3, 2013 at 10:22 am #

        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

        • kento December 4, 2013 at 1:31 pm #

          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

  4. Guy November 24, 2013 at 4:57 pm #

    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

    • antonio November 25, 2013 at 10:34 am #

      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

  5. Brad Ungar January 28, 2014 at 1:01 am #

    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!

    • kento February 1, 2014 at 11:03 am #

      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.

  6. James February 19, 2014 at 5:44 pm #

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

    Thanks 🙂

    James

    • kento February 20, 2014 at 12:06 pm #

      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?

  7. James February 21, 2014 at 6:46 am #

    Hi,

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

    Thanks 🙂

    • kento February 23, 2014 at 10:53 am #

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

  8. Bernice July 18, 2014 at 1:46 pm #

    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.

    • kento July 18, 2014 at 6:57 pm #

      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>

      • Bernice July 18, 2014 at 11:07 pm #

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

  9. Denislav September 18, 2014 at 6:59 pm #

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

    • kento September 20, 2014 at 6:38 pm #

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

  10. Steve March 22, 2016 at 8:10 pm #

    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?

    • antonio March 23, 2016 at 9:51 am #

      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.

  11. Orlando May 4, 2016 at 7:35 am #

    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!

    • antonio May 4, 2016 at 2:00 pm #

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

  12. Tushar Sharma May 24, 2016 at 5:19 am #

    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

    • antonio May 24, 2016 at 7:46 am #

      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.

  13. anu June 29, 2016 at 5:17 am #

    valid short code not working

    • antonio June 29, 2016 at 7:55 am #

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

  14. Alexey July 22, 2016 at 9:11 pm #

    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?

    • antonio July 25, 2016 at 8:02 am #

      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.

  15. 70599 September 5, 2016 at 6:36 pm #

    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]
    ');
    }
    ?>

    • Kento September 6, 2016 at 8:40 am #

      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

      • 70599 September 29, 2016 at 11:25 am #

        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.

        • Kento October 3, 2016 at 10:19 am #

          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

  16. Aharon September 11, 2016 at 3:53 pm #

    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?

    • antonio September 12, 2016 at 10:20 am #

      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.

  17. EA September 16, 2016 at 4:18 pm #

    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

    • antonio September 16, 2016 at 6:35 pm #

      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.

  18. James Rivas November 23, 2016 at 10:04 pm #

    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.

    • antonio November 24, 2016 at 10:35 am #

      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. GeoffatMM December 14, 2016 at 11:36 pm #

    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.

    • antonio December 20, 2016 at 9:52 am #

      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.

  20. Geoff December 20, 2016 at 1:41 pm #

    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.

    • antonio December 22, 2016 at 9:59 am #

      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.

  21. Bertie Song July 17, 2017 at 3:24 pm #

    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!

    • antonio July 17, 2017 at 5:19 pm #

      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.

Leave a Reply