1. Documentation
  2. Plugins
  3. WooCommerce
  4. Extensions
  5. Smart Coupons

How to auto-generate coupons (using shortcode)

Smart Coupons provide a powerful, “all-in-one” solution for gift certificates, store credits, discount coupons, and vouchers extending the core functionality of WooCommerce coupons.

This doc article explains how you can use Smart Coupons shortcode to either display a coupon or auto-generate & display a coupon for logged in users.

Smart Coupons shortcodes have many features from ‘showing a coupon’ to ‘automatically creating and/or showing a coupon for the current user’.

Smart Coupons shortcode will do nothing if it is embedded on a page or (custom) post and a guest user is accessing it. Shortcode will only work for registered and logged in users.

In order to add a coupon to a page, go to a post, and in the visual editor, select the coupon icon.

Smart Coupons: Shortcode button

In the pop-up, type the coupon code, select one from the search result. Then select Insert Shortcode.

Smart Coupons Shortcode Creator
Smart Coupons Shortcode Creator

In the editor, you’ll now see [smart_coupons] with a few attributes added.

Within the shortcode, several other attributes can be added, most of them correspond with the settings you would normally find when creating a coupon. All of them follow the following order: attribute="value". For example, coupon_amount="20". These extra attributes are handy if you do not want to create the coupon beforehand.

  • coupon_code: If this attribute is set, the plugin will look for the coupon in your store. If found, it’ll simply display it. If not found, it’ll create a new coupon with the provided coupon code. When it’ll try to create a new coupon, it’ll need coupon amount and discount type. If an amount is not provided, it’ll create a new coupon with zero amount. If discount type not provided it’ll set the discount type to smart_coupon which is nothing but a Store Credit
  • coupon_style. The styling of the coupon.
  • discount_type. Default: ‘smart_coupon’
  • coupon_amount. The amount of the coupon.
  • individual_use. Default: ‘no’
  • product_ids.
  • exclude_product_ids.
  • usage_limit.
  • usage_limit_per_user.
  • limit_usage_to_x_items.
  • expiry_date.
  • apply_before_tax. Default: ‘no’
  • free_shipping. Default: ‘no’
  • product_categories.
  • exclude_product_categories.
  • minimum_amount.
  • maximum_amount.
  • exclude_sale_items. Default: ‘no’
  • auto_generate Default: ‘no’
  • coupon_prefix.
  • coupon_suffix.
  • customer_email.
  • disable_email. Default: ‘no’

Case 1: Generate a unique code for each logged-in user ↑ Back to top

Here, you want your registered customer to see a new unique code for coupon/credit, which will be used by this customer only.

  • For credit: You can enter following code in the editor of page or post: [smart_coupons coupon_amount="12" coupon_style="dashed green medium"]. This will create a new store credit having amount 12 and will display the code with style.
    Important: Above code will keep creating a new store credit on each refresh of that page or post in which it is included.
  • For coupon: First, create a coupon and make sure that Auto Generate is enabled. Then, go to the page or post and add the coupon with the shortcode. It should look like this: [smart_coupons coupon_code="50_percent_cart" coupon_style="dashed red medium"].

Case 2: Display the same coupon code for all logged-in users ↑ Back to top

Here, you want all your registered user to see same coupon code and it should not be valid for a guest user or visitor. By default, limiting coupons to registered users only is not an option, but it is possible with Smart Coupons.

By adding a shortcode, email restrictions will be added to the coupon automatically, and they will only be available for logged-in users.

  • For credit: Not applicable. Credit can only be used for unique users.
  • For coupon: First, create a coupon and make sure Auto Generate is disabled. Then, go to the page or post and add the coupon with the shortcode.


The most customizable eCommerce platform for building your online business.

  • 30 day money back guarantee
  • Support teams across the world
  • Safe & Secure online payment