#53299·woocommerce

Coupon product inclusion restrictions not work when the Brand inclusion restriction is set

Author: ianlinCreated Nov 29, 2024Updated Sep 18, 2026
LabelsBugProduct/Inventory Managementneeds: developer feedbackKirigami

Prerequisites

  • I have carried out troubleshooting steps and I believe I have found a bug.
  • I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug

In coupon usage restrictions, when both Products and Product Brands are set, the products included in Products will still be unable to apply the coupon.

In Brands it uses a filter for checking product brands inclusion after the product inclusion validation, but it did not take it into account.

The filter has a third parameter which is a discount object, it could potentially recheck the product inclusion while verifying brands inclusion using that discount object.

Expected behavior

The product included in coupon's product inclusion restriction should be able to apply the coupon when the product brands restriction is also set.

Actual behavior

The product included in coupon's product inclusion restriction is unable to apply the coupon when the product brands restriction is also set.

Steps to reproduce

  1. Using WC >= 9.4
  2. Enable Brands feature by updating two options wc_feature_woocommerce_brands_enabled and woocommerce_remote_variant_assignment
    bash
    wp option update wc_feature_woocommerce_brands_enabled 'yes'
    wp option update woocommerce_remote_variant_assignment 2
  3. Create some brands from Products > Brands, e.g. Screenshot 2024-11-27 at 14 58 11
  4. Add some products to each of the brand that just created, e.g.

https://github.com/user-attachments/assets/1a6c0fac-2939-408d-9ade-96ba27ac45d8

  1. Create a coupon, add products and product brands inclusion restrictions to it Image
  2. Go to the store, add the product from the product inclusion restriction to cart (in the above screenshot example, add a Hoodie to cart)
  3. Go to the cart, apply the above coupon.
  4. It shows Sorry, this coupon is not applicable to your cart contents.

https://github.com/user-attachments/assets/22377c76-f145-4cca-b237-a13ff1ce1c1b

WordPress Environment

System Status Report
### WordPress Environment ###

WordPress address (URL): [Redacted]
Site address (URL): [Redacted]
WC Version: 9.4.2
Legacy REST API Package Version: The Legacy REST API plugin is not installed on this site.
Action Scheduler Version: ✔ 3.8.2
Log Directory Writable: ✔
WP Version: 6.7.1
WP Multisite: –
WP Memory Limit: 256 MB
WP Debug Mode: –
WP Cron: ✔
Language: en_US
External object cache: –

### Server Environment ###

Server Info: nginx/1.25.4
PHP Version: 8.2.13
PHP Post Max Size: 0 B
PHP Time Limit: 30
PHP Max Input Vars: 1000
cURL Version: 7.81.0
OpenSSL/3.0.2

SUHOSIN Installed: –
MySQL Version: 10.3.39-MariaDB-1:10.3.39+maria~ubu2004
Max Upload Size: 0 B
Default Timezone is UTC: ✔
fsockopen/cURL: ✔
SoapClient: ✔
DOMDocument: ✔
GZip: ✔
Multibyte String: ✔
Remote Post: ✔
Remote Get: ✔

### Database ###

[REDACTED]

### Post Type Counts ###

attachment: 23
aw_workflow: 8
event_ticket: 5
page: 13
post: 1
product: 28
product_variation: 9
revision: 17
shop_coupon: 8
shop_order: 65
shop_order_refund: 1
shop_subscription: 5
wp_font_face: 33
wp_font_family: 12
wp_global_styles: 1
wp_navigation: 1
wp_template: 3
wp_template_part: 2
wpcode: 3

### Security ###

Secure connection (HTTPS): ✔
Hide errors from visitors: ✔

### Active Plugins (12) ###

AutomateWoo: by WooCommerce – 6.1.0 (update to version 6.1.2 is available)
Code Snippets: by Code Snippets Pro – 3.6.4
Google for WooCommerce: by WooCommerce – 2.9.0
WCS Variables: by WooCommerce – 0.1
WooCommerce Analytics: by WooCommerce – 0.9.0
WooCommerce Beta Tester: by WooCommerce – 2.3.2
WooCommerce Stripe Gateway: by Stripe – 8.8.2
WooCommerce Subscriptions: by WooCommerce – 6.6.1 (update to version 6.9.1 is available)
WooCommerce: by Automattic – 9.4.2
WordPress Beta Tester: by WordPress Upgrade/Install Team – 3.5.6
WP Mail SMTP: by WP Mail SMTP – 4.1.1
WPForms Lite: by WPForms – 1.9.0.4

### Inactive Plugins (4) ###

Akismet Anti-spam: Spam Protection: by Automattic - Anti-spam Team – 5.3.5
Hello Dolly: by Matt Mullenweg – 1.7.2
Jetpack: by Automattic – 13.8.2
WooCommerce Bookings: by WooCommerce – 2.1.2 (update to version 2.2.1 is available)

### Settings ###

Legacy API Enabled: –
Force SSL: –
Currency: GBP (£)
Currency Position: left
Thousand Separator: ,
Decimal Separator: .
Number of Decimals: 0
Taxonomies: Product Types: bundle (bundle)
external (external)
grouped (grouped)
simple (simple)
subscription (subscription)
variable (variable)
variable subscription (variable-subscription)
woosb (woosb)

Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
exclude-from-search (exclude-from-search)
featured (featured)
outofstock (outofstock)
rated-1 (rated-1)
rated-2 (rated-2)
rated-3 (rated-3)
rated-4 (rated-4)
rated-5 (rated-5)

Connected to WooCommerce.com: –
Enforce Approved Product Download Directories: ✔
HPOS feature enabled: ✔
Order datastore: Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore
HPOS data sync enabled: ✔

### Logging ###

Enabled: ✔
Handler: Automattic\WooCommerce\Internal\Admin\Logging\LogHandlerFileV2
Retention period: 30 days
Level threshold: –
Log directory size: 1 MB

### WC Pages ###

Shop base: #7 - /shop/
Cart: #8 - /cart/ -  Contains the woocommerce/cart block
Checkout: #369 - /checkout/ -  Contains the woocommerce/checkout block
My account: #10 - /my-account/
Terms and conditions: ❌ Page not set

### Theme ###

Name: Twenty Twenty-Four
Version: 1.3
Author URL: https://wordpress.org
Child Theme: ❌ – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme
WooCommerce Support: ❌ Not declared

### Templates ###

Overrides: /var/www/html/wp-content/plugins/woocommerce/templates/block-notices/error.php
/var/www/html/wp-content/plugins/woocommerce/templates/block-notices/notice.php
/var/www/html/wp-content/plugins/woocommerce/templates/block-notices/success.php


### Subscriptions ###

WCS_DEBUG: ✔ No
Subscriptions Mode: ✔ Live
Subscriptions Live URL: https://ian-local-test-wp.ngrok.io
Subscriptions-core Library Version: 7.4.2
Subscription Statuses: wc-active: 2
wc-pending: 3

WooCommerce Account Connected: ❌ No
Report Cache Enabled: ✔ Yes
Cache Update Failures: ✔ 0 failure

### Store Setup ###

Country / State: United Kingdom (UK)

### Subscriptions by Payment Gateway ###

Stripe: wc-active: 2

### Payment Gateway Support ###

Stripe: products
refunds
tokenization
add_payment_method
subscriptions
subscription_cancellation
subscription_suspension
subscription_reactivation
subscription_amount_changes
subscription_date_changes
subscription_payment_method_change
subscription_payment_method_change_customer
subscription_payment_method_change_admin
multiple_subscriptions

Cash on delivery: products

### Admin ###

Enabled Features: activity-panels
analytics
product-block-editor
coupons
core-profiler
customize-store
customer-effort-score-tracks
import-products-task
experimental-fashion-sample-products
shipping-smart-defaults
shipping-setting-tour
homescreen
marketing
mobile-app-banner
navigation
onboarding
onboarding-tasks
pattern-toolkit-full-composability
product-custom-fields
remote-inbox-notifications
remote-free-extensions
payment-gateway-suggestions
printful
shipping-label-banner
subscriptions
store-alerts
transient-notices
woo-mobile-welcome
wc-pay-promotion
wc-pay-welcome-page
launch-your-store

Disabled Features: product-data-views
experimental-blocks
minified-js
product-pre-publish-modal
settings
async-product-editor-category-field
product-editor-template-system
blueprint
reactify-classic-payments-settings
use-wp-horizon
beta-tester-slotfill-examples

Daily Cron: ✔ Next scheduled: 2024-11-30 07:19:31 +00:00
Options: ✔
Notes: 93
Onboarding: completed

### Action Scheduler ###

Canceled: 2
Oldest: 2024-11-07 02:50:19 +0000
Newest: 2024-11-25 02:15:20 +0000

Complete: 7,620
Oldest: 2024-11-07 02:50:19 +0000
Newest: 2024-11-29 08:40:55 +0000

Failed: 20,470
Oldest: 2024-02-29 08:30:47 +0000
Newest: 2024-11-28 02:45:17 +0000

Pending: 22
Oldest: 2024-11-29 08:42:53 +0000
Newest: 2024-12-11 07:42:39 +0000


### Status report information ###

Generated at: 2024-11-29 08:41:12 +00:00

Isolating the problem

  • I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • This bug happens with a default WordPress theme active, or Storefront.
  • I can reproduce this bug consistently using the steps above.