1. Documentation /
  2. Extensions /
  3. Smart Coupons /
  4. URL Coupons – How to Apply Single or Multiple Coupons on Click of a Link

URL Coupons – How to Apply Single or Multiple Coupons on Click of a Link

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

This doc article explains how using Smart Coupons plugin, you can add a unique coupon code(s) to the URL. When a user clicks on that URL, the coupon(s) gets automatically applied and (optionally) add products to the customer’s shopping cart.

Another thing, you can also add the coupon code to any custom URL on your site and allow the discount to get automatically applied on clicking that URL.

This is a very useful feature. Your users don’t have to type & apply the coupons manually. Instead, they just have to click on the provided link. No coupon code hassles, easy sharing.

Apply a single coupon via a link (Coupon URL) ↑ Back to top

  1. Go to your WordPress admin panel. Under Marketing > Coupons, click on Add coupon. You can also modify your existing coupon.
  2. Set the discount type, coupon amount, expiry, set usage limit and restrictions and other settings as per your requirements. Publish/update the coupon.
  3. Under ‘Coupon shareable link’, you’ll find a button ‘Click to copy’.
  4. Click on the button to copy the link & share it via email, social media, deal sites, etc.
  5. Once any user clicks on that URL, the coupon gets auto-applied.

For example, your shop URL is https://www.fashionworld.com/shop/. Then you can embed a coupon code to the URL like this – https://www.fashionworld.com/shop/?coupon-code=specialsale10&sc-page=shop.

Apply multiple coupons via a link (Coupon URL) ↑ Back to top

You can also add multiple coupon codes to the URL and apply multiple coupons via that single URL. Pass a comma-separated list of coupons in the link as shown – https://www.fashionworld.com/product/trendingwatch/?coupon-code=specialsale10,holiday15,exclusivedisc5&sc-page=shop

Note – In the case of more than five coupon codes in the URL, only the first five coupons will be auto-applied. To apply more than five coupons via URL, the Smart Coupons plugin provides a hook for it.

Check the following sample code about how you can use the hook to increase the limit to 10. If you want to know about the best way to add a custom code to your website refer to this document: Customizing WooCommerce: Best Practices

/**
 * Function to modify the number of coupons allowed to be applied from a URL
 * 
 * @author StoreApps (https://www.storeapps.org/)
 *
 * @param integer $limit The limit.
 * @return integer
 */
function storeapps_wc_sc_max_url_coupons_limit( $limit = 5 ) {
    $limit = 10;
    return $limit;
}
function storeapps_handle_smart_coupons_hooks() {
    add_filter( 'wc_sc_max_url_coupons_limit', 'storeapps_wc_sc_max_url_coupons_limit', 11 );
}
add_action( 'wp_loaded', 'storeapps_handle_smart_coupons_hooks' );

Redirect to a page after coupon is applied ↑ Back to top

Smart Coupons provides a URL param sc-page for redirecting to a page after coupon gets applied via URL. By default, the user gets redirected to the shop page. Following is the list of possible values that you can use as sc-page.

WooCommerce predefined pages ↑ Back to top

If you want to use pages that are defined by the WooCommerce you can use either shop, cart, checkout or my-account

If the target page is the shop page then the link will be like

https://www.fashionworld.com/?coupon-code=specialsale10&sc-page=shop

Page ID ↑ Back to top

You can also use the numeric page id of the target page.

If the page id of the target page is 123 then the link will be like:

https://www.fashionworld.com/?coupon-code=holiday15&sc-page=123

Page path ↑ Back to top

You can also use the path of the target page with respect to the website.

If the target page is https://www.fashionworld.com/landing-page/ then the link will be like:

https://www.fashionworld.com/?coupon-code=exclusivedisc5&sc-page=landing-page

WooCommerce

The most customizable eCommerce platform for building your online business.

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