mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-08 21:52:55 +08:00
Add shipping tax to taxes instead of shipping
This commit is contained in:
parent
a926aa7ca3
commit
afd77cf9da
2 changed files with 8 additions and 7 deletions
|
@ -76,12 +76,12 @@ class AmountFactory {
|
||||||
$item_total = $cart->get_cart_contents_total() + $cart->get_discount_total() + $total_fees_amount;
|
$item_total = $cart->get_cart_contents_total() + $cart->get_discount_total() + $total_fees_amount;
|
||||||
$item_total = new Money( (float) $item_total, $this->currency );
|
$item_total = new Money( (float) $item_total, $this->currency );
|
||||||
$shipping = new Money(
|
$shipping = new Money(
|
||||||
(float) $cart->get_shipping_total() + $cart->get_shipping_tax(),
|
(float) $cart->get_shipping_total(),
|
||||||
$this->currency
|
$this->currency
|
||||||
);
|
);
|
||||||
|
|
||||||
$taxes = new Money(
|
$taxes = new Money(
|
||||||
$cart->get_subtotal_tax(),
|
$cart->get_subtotal_tax() + $cart->get_shipping_tax(),
|
||||||
$this->currency
|
$this->currency
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ class AmountFactory {
|
||||||
$currency
|
$currency
|
||||||
);
|
);
|
||||||
$shipping = new Money(
|
$shipping = new Money(
|
||||||
(float) $order->get_shipping_total() + (float) $order->get_shipping_tax(),
|
(float) $order->get_shipping_total(),
|
||||||
$currency
|
$currency
|
||||||
);
|
);
|
||||||
$taxes = new Money(
|
$taxes = new Money(
|
||||||
|
|
|
@ -41,8 +41,9 @@ class ItemFactory {
|
||||||
* @return Item[]
|
* @return Item[]
|
||||||
*/
|
*/
|
||||||
public function from_wc_cart( \WC_Cart $cart ): array {
|
public function from_wc_cart( \WC_Cart $cart ): array {
|
||||||
$items = array_map(
|
$shipping_tax = round( $cart->get_shipping_tax(), 2 ) ?? 0;
|
||||||
function ( array $item ): Item {
|
$items = array_map(
|
||||||
|
function ( array $item ) use ( $shipping_tax ): Item {
|
||||||
$product = $item['data'];
|
$product = $item['data'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +57,7 @@ class ItemFactory {
|
||||||
$price_without_tax = (float) wc_get_price_excluding_tax( $product );
|
$price_without_tax = (float) wc_get_price_excluding_tax( $product );
|
||||||
$price_without_tax_rounded = round( $price_without_tax, 2 );
|
$price_without_tax_rounded = round( $price_without_tax, 2 );
|
||||||
$tax = round( $price - $price_without_tax_rounded, 2 );
|
$tax = round( $price - $price_without_tax_rounded, 2 );
|
||||||
$tax = new Money( $tax, $this->currency );
|
$tax = new Money( $tax + $shipping_tax, $this->currency );
|
||||||
return new Item(
|
return new Item(
|
||||||
mb_substr( $product->get_name(), 0, 127 ),
|
mb_substr( $product->get_name(), 0, 127 ),
|
||||||
new Money( $price_without_tax_rounded, $this->currency ),
|
new Money( $price_without_tax_rounded, $this->currency ),
|
||||||
|
@ -137,7 +138,7 @@ class ItemFactory {
|
||||||
$price_without_tax = (float) $order->get_item_subtotal( $item, false );
|
$price_without_tax = (float) $order->get_item_subtotal( $item, false );
|
||||||
$price_without_tax_rounded = round( $price_without_tax, 2 );
|
$price_without_tax_rounded = round( $price_without_tax, 2 );
|
||||||
$tax = round( $price - $price_without_tax_rounded, 2 );
|
$tax = round( $price - $price_without_tax_rounded, 2 );
|
||||||
$tax = new Money( $tax, $currency );
|
$tax = new Money( $tax + (float) $order->get_shipping_tax(), $currency );
|
||||||
return new Item(
|
return new Item(
|
||||||
mb_substr( $product->get_name(), 0, 127 ),
|
mb_substr( $product->get_name(), 0, 127 ),
|
||||||
new Money( $price_without_tax_rounded, $currency ),
|
new Money( $price_without_tax_rounded, $currency ),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue