mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Rename fees session to avoid naming conflicts
This commit is contained in:
parent
beafb7b56b
commit
cc87fb50a3
3 changed files with 22 additions and 16 deletions
|
@ -49,9 +49,12 @@ class AmountFactory {
|
|||
$total = new Money( (float) $cart->get_total( 'numeric' ), $currency );
|
||||
|
||||
$total_fees_amount = 0;
|
||||
foreach ( WC()->session->get( 'fees' ) as $fee ) {
|
||||
$fees = WC()->session->get( 'ppcp_fees' );
|
||||
if ( $fees ) {
|
||||
foreach ( WC()->session->get( 'ppcp_fees' ) as $fee ) {
|
||||
$total_fees_amount += (float) $fee->amount;
|
||||
}
|
||||
}
|
||||
|
||||
$item_total = $cart->get_cart_contents_total() + $cart->get_discount_total() + $total_fees_amount;
|
||||
$item_total = new Money( (float) $item_total, $currency );
|
||||
|
|
|
@ -57,6 +57,9 @@ class ItemFactory {
|
|||
$cart->get_cart_contents()
|
||||
);
|
||||
|
||||
$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(
|
||||
|
@ -67,8 +70,9 @@ class ItemFactory {
|
|||
new Money( (float) $fee->tax, $currency )
|
||||
);
|
||||
},
|
||||
WC()->session->get( 'fees' )
|
||||
$fees_from_session
|
||||
);
|
||||
}
|
||||
|
||||
return array_merge( $items, $fees );
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\ApiClient;
|
||||
|
||||
use Dhii\Container\ServiceProvider;
|
||||
use Dhii\Modular\Module\Exception\ModuleExceptionInterface;
|
||||
use Dhii\Modular\Module\ModuleInterface;
|
||||
use Interop\Container\ServiceProviderInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
@ -43,7 +42,7 @@ class ApiModule implements ModuleInterface {
|
|||
function ( \WC_Cart $cart ) {
|
||||
$fees = $cart->fees_api()->get_fees();
|
||||
if ( $fees ) {
|
||||
WC()->session->set( 'fees', $fees );
|
||||
WC()->session->set( 'ppcp_fees', $fees );
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue