How to Exclude Sale Items or Specific Products from Cart Abandonment Coupons
Content
A common challenge for store owners using the WooCommerce Cart Abandonment Recovery plugin is managing how automatically generated discount coupons are applied. Many merchants run promotions and do not want to stack an abandoned cart discount on top of an existing sale price, or they need to exclude certain products like gift cards from being discounted.
Based on community support threads, the plugin's settings do not include a native option to exclude sale items or specific product IDs from coupons it generates. This occurs because the automatic coupon generation feature applies the discount to the entire cart contents without the fine-grained control found in manually created WooCommerce coupons.
Solution: Using a Custom Code Snippet
The most reliable solution provided by the plugin's team is to use a custom PHP filter. This code modifies the coupon data as it is generated, allowing you to set standard WooCommerce coupon parameters.
To exclude specific product IDs:
add_filter('woo_ca_generate_coupon', 'update_coupon_options');
function update_coupon_options( $coupon_post_data ){
$coupon_post_data['exclude_product_ids'] = array( 123, 456 ); // Replace with your product IDs
return $coupon_post_data;
}To exclude all items that are on sale:
add_filter('woo_ca_generate_coupon', 'update_coupon_options');
function update_coupon_options( $coupon_post_data ){
$coupon_post_data['exclude_sale_items'] = 'yes';
return $coupon_post_data;
}Important Implementation Notes:
- This code must be added to your child theme's
functions.phpfile. Adding it to a parent theme's file is not recommended, as your changes will be lost when the theme updates. - Always use a comma to separate multiple product IDs within the array.
- Test the code on a staging site first to ensure it works as expected and does not cause conflicts with other plugins or your theme.
Limitations and Considerations
It is important to understand the scope of this solution:
- Email Triggering: This code only affects the coupon itself. It will not prevent an abandoned cart notification email from being sent if a sale item is in the cart. The email will still be sent, just without a valid coupon for the sale items.
- Cart Value/Product Exclusion: There is currently no supported method to completely prevent an abandoned cart from being tracked or to stop an email from being sent based on the cart's contents (e.g., if it contains a gift card) or its total value. The 'WooCommerce Cart Abandonment Recovery' team has stated this is not a native feature.
- Manual Coupon Alternative: For maximum control, you can bypass the automatic coupon generation entirely. Manually create a coupon in WooCommerce with all your desired restrictions (product exclusions, sale item exclusions, minimum spend, etc.) and then select that specific coupon within your abandoned cart email template settings.
While not a built-in feature, using the provided filter code offers a powerful workaround for controlling which products are eligible for abandoned cart discounts.
Related Support Threads Support
-
Products on Salehttps://wordpress.org/support/topic/products-on-sale-3/
-
Is it Possible to Exclude some products? or Cart Value?https://wordpress.org/support/topic/is-it-possible-to-exclude-some-products-or-cart-value/
-
exclude coupons from sale items.https://wordpress.org/support/topic/exclude-coupons-from-sale-items/
-
Coupons exclude sale productshttps://wordpress.org/support/topic/coupons-exclude-sale-products/
-
Exclude coupon for sales itemshttps://wordpress.org/support/topic/exclude-coupon-for-sales-items/
-
Exclude products from triggering abandoned cartshttps://wordpress.org/support/topic/exclude-products-from-triggering-abandoned-carts/
-
Exclude certain producthttps://wordpress.org/support/topic/exclude-certain-product/
-
Exclude single item from coupon discountshttps://wordpress.org/support/topic/exclude-single-item-from-coupon-discounts/
-
How to Set Minimum amount to apply the Coupon Codehttps://wordpress.org/support/topic/how-to-set-minimum-amount-to-apply-the-coupon-code/
-
Restriction for items in salehttps://wordpress.org/support/topic/restriction-for-items-in-sale/
-
Coupons creator with exclude_sale_items optionhttps://wordpress.org/support/topic/coupons-creator-with-exclude_sale_items-option/
-
To send an email only when a coupon is generatedhttps://wordpress.org/support/topic/to-send-an-email-only-when-a-coupon-is-generated/
-
Feature: Coupons Mapped to Productshttps://wordpress.org/support/topic/feature-coupons-mapped-to-products/
-
Exclude product from automated couponshttps://wordpress.org/support/topic/exclude-product-from-automated-coupons/
-
Adding conditional ruleshttps://wordpress.org/support/topic/adding-conditional-rules/
-
Exclude products/categorieshttps://wordpress.org/support/topic/exclude-products-categories/
-
Exclude specific countrieshttps://wordpress.org/support/topic/exclude-specific-countries-2/
-
How to use this new filter?https://wordpress.org/support/topic/how-to-use-this-new-filter/
-
exclude auto generated coupons from sales itemshttps://wordpress.org/support/topic/exclude-auto-generated-coupons-from-sales-items-2/
-
exclude auto generated coupons from sales itemshttps://wordpress.org/support/topic/exclude-auto-generated-coupons-from-sales-items/
-
How can I exclude a product from an auto generated couponhttps://wordpress.org/support/topic/how-can-i-exclude-a-product-from-an-auto-generated-coupon-2/
-
Option to Exclude sale items from the auto-generated coupon?https://wordpress.org/support/topic/option-to-exclude-sale-items-from-the-auto-generated-coupon/