mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Merge pull request #2906 from woocommerce/PCP-4014-Zero-Value-Free-Gift-Item-Causing-“CANNOT-BE-NEGATIVE”-Error
Fix negative unit amount adjustments in item sanitization
This commit is contained in:
commit
e948c43f73
1 changed files with 5 additions and 0 deletions
|
@ -178,6 +178,11 @@ class PurchaseUnitSanitizer {
|
||||||
// Get a more intelligent adjustment mechanism.
|
// Get a more intelligent adjustment mechanism.
|
||||||
$increment = ( new MoneyFormatter() )->minimum_increment( $item['unit_amount']['currency_code'] );
|
$increment = ( new MoneyFormatter() )->minimum_increment( $item['unit_amount']['currency_code'] );
|
||||||
|
|
||||||
|
// not floor items that will be negative then.
|
||||||
|
if ( (float) $item['unit_amount']['value'] < $increment ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$this->purchase_unit['items'][ $index ]['unit_amount'] = ( new Money(
|
$this->purchase_unit['items'][ $index ]['unit_amount'] = ( new Money(
|
||||||
( (float) $item['unit_amount']['value'] ) - $increment,
|
( (float) $item['unit_amount']['value'] ) - $increment,
|
||||||
$item['unit_amount']['currency_code']
|
$item['unit_amount']['currency_code']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue