Fix TypeError in WC_Discounts->apply_coupons() when being called a second time [redux] (#41602)
* Discounts are not in the format `array( 'string' => 'string' )`, they are in the format `array( 'string' => array( int, int ) );`. * Remove `ArrayUtil` because `ensure_key_is_array` creates the array and returns `true`. * Add Changelog manually * Fix changelog placement. --------- Co-authored-by: John Rom <john@nimblelight.com>
This commit is contained in:
parent
003c3c721e
commit
409a256815
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Fix `TypeError` in `WC_Discounts->apply_coupons()` when being called a second time.
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Automattic\WooCommerce\Utilities\NumberUtil;
|
use Automattic\WooCommerce\Utilities\NumberUtil;
|
||||||
use Automattic\WooCommerce\Utilities\StringUtil;
|
|
||||||
|
|
||||||
defined( 'ABSPATH' ) || exit;
|
defined( 'ABSPATH' ) || exit;
|
||||||
|
|
||||||
|
@ -257,7 +256,7 @@ class WC_Discounts {
|
||||||
}
|
}
|
||||||
|
|
||||||
$coupon_code = $coupon->get_code();
|
$coupon_code = $coupon->get_code();
|
||||||
if ( StringUtil::is_null_or_whitespace( $this->discounts[ $coupon_code ] ?? null ) ) {
|
if ( ! isset( $this->discounts[ $coupon_code ] ) || ! is_array( $this->discounts[ $coupon_code ] ) ) {
|
||||||
$this->discounts[ $coupon_code ] = array_fill_keys( array_keys( $this->items ), 0 );
|
$this->discounts[ $coupon_code ] = array_fill_keys( array_keys( $this->items ), 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue