Cherry pick 51577 into release/9.4 (#51776)
* Resolved fatal error when applying Brands-restricted coupon (#51577) * Resolved fatal error when applying Brands-restricted coupon * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions <github-actions@github.com> * Prep for cherry pick 51577 --------- Co-authored-by: Jason Kytros <jason.kytros@automattic.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: WooCommerce Bot <no-reply@woocommerce.com>
This commit is contained in:
parent
0c9eac081e
commit
135f6c9389
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue