Hello guys how are you? Welcome back on my blog therichpost.com. Guys today in this blog post you will see, Solved – WooCommerce Coupon Usage Limit has been Reached.
![Solved - WooCommerce Coupon Usage Limit has been Reached](https://therichpost.com/wp-content/uploads/2024/07/Solved-WooCommerce-Coupon-Usage-Limit-has-been-Reached-1024x469.png)
Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:
Guys there two methods to solve this kind of issue and here are they:
First : If you need to adjust the usage limits or check the current usage of the coupon, you can follow these steps in the WooCommerce admin panel:
- Navigate to Coupons:
- Go to WooCommerce > Coupons.
- Edit the Coupon:
- Find the coupon in question and click on its name to edit it.
- Check or Adjust Usage Limits:
- In the Usage limits tab, you can view and modify the usage restrictions:
- Usage limit per coupon: The maximum number of times this coupon can be used by all customers.
- Usage limit per user: The maximum number of times this coupon can be used by a single customer.
- Save Changes:
- After making any necessary adjustments, click the Update button to save the changes.
Second : We will increase the limit coupon usage with pragmatically add functions inside our theme’s functions.php file:
add_action('woocommerce_coupon_used', 'increase_coupon_usage_limit'); function increase_coupon_usage_limit($coupon_code) { // Get the coupon object $coupon = new WC_Coupon($coupon_code); // Get the current usage limit $usage_limit = $coupon->get_usage_limit(); // Increase the usage limit by 1 if ($usage_limit) { $new_usage_limit = $usage_limit + 1; $coupon->set_usage_limit($new_usage_limit); $coupon->save(); } }
Explanation:
woocommerce_coupon_used
: This hook is triggered every time a coupon is used.increase_coupon_usage_limit
: The function to handle the hook.WC_Coupon($coupon_code)
: Create a coupon object using the coupon code.get_usage_limit()
: Get the current usage limit of the coupon.set_usage_limit($new_usage_limit)
: Set the new usage limit.save()
: Save the coupon changes.
If you need further assistance or details about how to manage WooCommerce coupons, feel free to ask!
This is it guys and if you will have any kind of query, suggestion or requirement then feel free to comment below.
Jassa
Developer’s King
Thanks
Recent Comments