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.
In the pop-up, type the coupon code, select one from the search result. Then select Insert Shortcode.
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_couponwhich 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’
apply_before_tax. Default: ‘no’
free_shipping. Default: ‘no’
exclude_sale_items. Default: ‘no’
disable_email. Default: ‘no’
Case 1: Generate a unique code for each logged-in user
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.