mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Fix order fees total
This commit is contained in:
parent
04aba8ceb1
commit
af15246a96
3 changed files with 42 additions and 4 deletions
|
@ -6,6 +6,7 @@ namespace WooCommerce\PayPalCommerce\Tests\E2e\Order;
|
|||
use Exception;
|
||||
use WC_Coupon;
|
||||
use WC_Order;
|
||||
use WC_Order_Item_Fee;
|
||||
use WC_Order_Item_Product;
|
||||
use WC_Order_Item_Shipping;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
||||
|
@ -79,6 +80,17 @@ class PurchaseUnitTest extends TestCase
|
|||
$wcOrder->add_item($shipping);
|
||||
}
|
||||
|
||||
foreach ($data['fees'] ?? [] as $ind => $feeData) {
|
||||
$fee = new WC_Order_Item_Fee();
|
||||
$fee->set_name("Test fee $ind");
|
||||
$fee->set_amount((string) $feeData['amount']);
|
||||
$fee->set_total((string) $feeData['amount']);
|
||||
$fee->set_tax_class('');
|
||||
$fee->set_tax_status('taxable');
|
||||
|
||||
$wcOrder->add_item($fee);
|
||||
}
|
||||
|
||||
$wcOrder->calculate_totals();
|
||||
$wcOrder->save();
|
||||
|
||||
|
@ -213,6 +225,26 @@ class PurchaseUnitTest extends TestCase
|
|||
],
|
||||
]),
|
||||
];
|
||||
yield [
|
||||
[
|
||||
'items' => [
|
||||
['price' => 5.99, 'quantity' => 1],
|
||||
],
|
||||
'billing' => ['city' => 'city1'],
|
||||
'fees' => [
|
||||
['amount' => 2.89],
|
||||
['amount' => 7.13],
|
||||
]
|
||||
],
|
||||
self::adaptAmountFormat([
|
||||
'value' => 17.39,
|
||||
'breakdown' => [
|
||||
'item_total' => 16.01,
|
||||
'tax_total' => 1.38,
|
||||
'shipping' => 0.0,
|
||||
],
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
private static function adaptAmountFormat(array $data, string $currency = null): array {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue