mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
Fix negative unit amount adjustments in item sanitization
This commit is contained in:
parent
03c6badcad
commit
9c447835ab
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