Apply a WooCommerce Coupon Code to the Cart Via URL

This code recipe sets up a direct link to your WooCommerce cart page that automatically applies the coupon code. Now you can offer a more foolproof shopping experience and show buyers the exact discount for their active cart.

Use this recipe in combination with our tutorial to hide the Coupon Code field in WooCommerce for an even tighter, more controlled shopping experience.

Apply a WooCommerce Coupon Code to the Cart Via URL

How to Share Coupon Codes in the URL

Below are three example URLs for your store that pass the discount or coupon code and automatically apply the code on the customer’s cart.

Direct URL to the cart page with the coupon code ‘loyal’.


Add a specific product (by ID) to the cart and automatically apply the coupon code ‘loyal’. This is a great way to drive checkout conversions for a single product on sale.


Direct users right to the checkout page with a specific product (by ID) added to their cart and automatically applied coupon code ‘loyal’.


The Code Recipe

Adding the Recipe to Your Website

You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. We have a post on how to create a customizations plugin on our partner website, Paid Memberships Pro.

Automatic Coupon Applied via Sitewide Sales

Sitewide Sales is a new way to run sales for your WordPress-powered ecommerce site. Using Sitewide Sales, you can set up an active promotion that runs from your set start time and end time.

The plugin automatically applies discounts according to the rules you set up—no coding required. If you want to run a true sale that automatically applies a discount without the need for manual coupon entry, you need try the Sitewide Sales plugin—it works with WooCommerce and other popular ecommerce plugins for WordPress.

Kim Coleman
Kim Coleman

Hi! I'm Kim Coleman, an internet entrepreneur from Reading, PA. I've been working with WordPress for over 15 years. In 2011, I founded Paid Memberships Pro, a complete plugin for Recurring Subscriptions and Content Restriction with 100k active sites. I'm currently working on our new product, Sitewide Sales.

Articles: 35