Rename fees session to avoid naming conflicts

This commit is contained in:
dinamiko 2021-08-16 10:37:17 +02:00
parent beafb7b56b
commit cc87fb50a3
3 changed files with 22 additions and 16 deletions

View file

@ -57,18 +57,22 @@ class ItemFactory {
$cart->get_cart_contents()
);
$fees = array_map(
static function ( \stdClass $fee ) use ( $currency ): Item {
return new Item(
$fee->name,
new Money( (float) $fee->amount, $currency ),
1,
'',
new Money( (float) $fee->tax, $currency )
);
},
WC()->session->get( 'fees' )
);
$fees = array();
$fees_from_session = WC()->session->get( 'ppcp_fees' );
if ( $fees_from_session ) {
$fees = array_map(
static function ( \stdClass $fee ) use ( $currency ): Item {
return new Item(
$fee->name,
new Money( (float) $fee->amount, $currency ),
1,
'',
new Money( (float) $fee->tax, $currency )
);
},
$fees_from_session
);
}
return array_merge( $items, $fees );
}