Created
May 22, 2026 10:42
-
-
Save rajeshsingh520/2d8d80afaa2668b2c1836737e758f75a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter('woocommerce_paypal_payments_purchase_unit_from_wc_order', function ($purchase_unit, $order) { | |
| if (!$purchase_unit instanceof \WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit || !$order instanceof \WC_Order) { | |
| return $purchase_unit; | |
| } | |
| $actual_total = (float)$order->get_total(); | |
| $new_money = new \WooCommerce\PayPalCommerce\ApiClient\Entity\Money( | |
| $actual_total, | |
| $order->get_currency() | |
| ); | |
| $new_amount = new \WooCommerce\PayPalCommerce\ApiClient\Entity\Amount($new_money, null); | |
| $purchase_unit->set_amount($new_amount); | |
| return $purchase_unit; | |
| }, 10, 2); | |
| add_filter('ppcp_ditch_items_breakdown', function($ditch, $purchase_unit) { | |
| if ($purchase_unit instanceof \WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit) { | |
| if ($purchase_unit->amount()->breakdown() === null) { | |
| return true; | |
| } | |
| } | |
| return $ditch; | |
| }, 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment