From 24586d09109bb1dc6f9c8e3540c6acd51f6fa644 Mon Sep 17 00:00:00 2001 From: Alex P Date: Wed, 15 Jun 2022 16:28:44 +0300 Subject: [PATCH] Send shipping/discount taxes as tax --- .../src/Factory/AmountFactory.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/modules/ppcp-api-client/src/Factory/AmountFactory.php b/modules/ppcp-api-client/src/Factory/AmountFactory.php index b021d8965..8bda79462 100644 --- a/modules/ppcp-api-client/src/Factory/AmountFactory.php +++ b/modules/ppcp-api-client/src/Factory/AmountFactory.php @@ -80,19 +80,19 @@ class AmountFactory { $item_total = $cart->get_cart_contents_total() + $cart->get_discount_total() + $total_fees_amount; $item_total = new Money( (float) $item_total, $this->currency ); $shipping = new Money( - (float) $cart->get_shipping_total() + $cart->get_shipping_tax(), + (float) $cart->get_shipping_total(), $this->currency ); $taxes = new Money( - $cart->get_subtotal_tax(), + (float) $cart->get_total_tax(), $this->currency ); $discount = null; if ( $cart->get_discount_total() ) { $discount = new Money( - (float) $cart->get_discount_total() + $cart->get_discount_tax(), + (float) $cart->get_discount_total(), $this->currency ); } @@ -126,7 +126,7 @@ class AmountFactory { $discount_value = array_sum( array( - (float) $order->get_total_discount( false ), // Only coupons. + (float) $order->get_total_discount(), // Only coupons. $this->discounts_from_items( $items ), ) ); @@ -167,17 +167,11 @@ class AmountFactory { $currency ); $shipping = new Money( - (float) $order->get_shipping_total() + (float) $order->get_shipping_tax(), + (float) $order->get_shipping_total(), $currency ); $taxes = new Money( - (float) array_reduce( - $items, - static function ( float $total, Item $item ): float { - return $total + $item->quantity() * $item->tax()->value(); - }, - 0 - ), + (float) $order->get_total_tax(), $currency );