Revert to original behavior
This commit is contained in:
parent
955a75bf30
commit
d0f47a7980
|
@ -1736,21 +1736,6 @@ class WC_Cart {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Check to see if an individual use coupon is set
|
||||
if ( $this->applied_coupons ) {
|
||||
foreach ( $this->applied_coupons as $code ) {
|
||||
$coupon = new WC_Coupon( $code );
|
||||
|
||||
if ( $coupon->get_individual_use() && false === apply_filters( 'woocommerce_apply_with_individual_use_coupon', false, $the_coupon, $coupon, $this->applied_coupons ) ) {
|
||||
|
||||
// Reject new coupon
|
||||
$coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_ALREADY_APPLIED_INDIV_USE_ONLY );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If its individual use then remove other coupons
|
||||
if ( $the_coupon->get_individual_use() ) {
|
||||
$coupons_to_keep = apply_filters( 'woocommerce_apply_individual_use_coupon', array(), $the_coupon, $this->applied_coupons );
|
||||
|
@ -1769,6 +1754,21 @@ class WC_Cart {
|
|||
}
|
||||
}
|
||||
|
||||
// Check to see if an individual use coupon is set
|
||||
if ( $this->applied_coupons ) {
|
||||
foreach ( $this->applied_coupons as $code ) {
|
||||
$coupon = new WC_Coupon( $code );
|
||||
|
||||
if ( $coupon->get_individual_use() && false === apply_filters( 'woocommerce_apply_with_individual_use_coupon', false, $the_coupon, $coupon, $this->applied_coupons ) ) {
|
||||
|
||||
// Reject new coupon
|
||||
$coupon->add_coupon_message( WC_Coupon::E_WC_COUPON_ALREADY_APPLIED_INDIV_USE_ONLY );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->applied_coupons[] = $coupon_code;
|
||||
|
||||
// Choose free shipping
|
||||
|
|
|
@ -645,7 +645,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
|
|||
$coupons = WC()->cart->get_coupons();
|
||||
|
||||
$this->assertEquals( count( $coupons ), 1 );
|
||||
$this->assertEquals( 'code1', reset( $coupons )->get_code() );
|
||||
$this->assertEquals( 'code2', reset( $coupons )->get_code() );
|
||||
|
||||
// Clean up
|
||||
WC()->cart->empty_cart();
|
||||
|
|
Loading…
Reference in New Issue