diff --git a/plugins/woocommerce/includes/class-wc-brands-coupons.php b/plugins/woocommerce/includes/class-wc-brands-coupons.php index 065ec3e0de7..d65dc334647 100644 --- a/plugins/woocommerce/includes/class-wc-brands-coupons.php +++ b/plugins/woocommerce/includes/class-wc-brands-coupons.php @@ -69,17 +69,17 @@ class WC_Brands_Coupons { // 1) Coupon has a brand requirement but no products in the cart have the brand. if ( ! $included_brands_match && ! empty( $brand_coupon_settings['included_brands'] ) ) { - throw new Exception( WC_Coupon::E_WC_COUPON_NOT_APPLICABLE ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped + throw new Exception( $coupon->get_coupon_error( WC_Coupon::E_WC_COUPON_NOT_APPLICABLE ), WC_Coupon::E_WC_COUPON_NOT_APPLICABLE ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped } // 2) All products in the cart match brand exclusion rule. if ( count( $items ) === $excluded_brands_matches ) { - throw new Exception( self::E_WC_COUPON_EXCLUDED_BRANDS ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped + throw new Exception( __( 'Sorry, this coupon is not applicable to the brands of selected products.', 'woocommerce' ), self::E_WC_COUPON_EXCLUDED_BRANDS ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped } // 3) For a cart discount, there is at least one product in cart that matches exclusion rule. if ( $coupon->is_type( 'fixed_cart' ) && $excluded_brands_matches > 0 ) { - throw new Exception( self::E_WC_COUPON_EXCLUDED_BRANDS ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped + throw new Exception( __( 'Sorry, this coupon is not applicable to the brands of selected products.', 'woocommerce' ), self::E_WC_COUPON_EXCLUDED_BRANDS ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped } return $valid; diff --git a/plugins/woocommerce/readme.txt b/plugins/woocommerce/readme.txt index 94831953d50..19773211970 100644 --- a/plugins/woocommerce/readme.txt +++ b/plugins/woocommerce/readme.txt @@ -173,6 +173,7 @@ WooCommerce comes with some sample data you can use to see how products look; im **WooCommerce** +* Fix - Resolved fatal error when applying Brands-restricted coupon [#51577](https://github.com/woocommerce/woocommerce/pull/51577) * Fix - Fix CSS issue with Safari 18.0 on the product form page. [#51734](https://github.com/woocommerce/woocommerce/pull/51734) * Fix - Add a new notice to the plugins list for products used without subscriptions reminding them to purchase. [#51060](https://github.com/woocommerce/woocommerce/pull/51060) * Fix - Added missing wp-block- classes to order confirmation, store notices, and breadcrumb blocks. [#51380](https://github.com/woocommerce/woocommerce/pull/51380)