Skip to content

Commit 666a70b

Browse files
committed
Fixed negative number being set on order payment amount
1 parent 0f1a70b commit 666a70b

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Fixed a bug where GraphQL queries using `relatedTo*` arguments within `hasProduct` or `hasVariant` inputs caused a server error. ([#4297](https://github.com/craftcms/commerce/issues/4297))
66
- Cart requests that include a`couponCode` param are now rate-limited. (GHSA-h5gm-x9wr-vhcm)
7+
- Fixed a bug where a negative payment amount could be set on an order. (GHSA-78vr-q6cf-c7p6)
78

89
## 5.6.4 - 2026-05-06
910

src/elements/Order.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,7 @@ public function getPaymentAmount(): float
26572657

26582658
/**
26592659
* Sets the order's payment amount in the order's currency. This amount is not persisted.
2660+
* This will remain null if set to zero or a negative number.
26602661
*
26612662
* @throws CurrencyException
26622663
* @throws InvalidConfigException
@@ -2665,7 +2666,10 @@ public function setPaymentAmount(float $amount): void
26652666
{
26662667
$paymentCurrency = Plugin::getInstance()->getPaymentCurrencies()->getPaymentCurrencyByIso($this->getPaymentCurrency());
26672668
$amount = Currency::round($amount, $paymentCurrency);
2668-
$this->_paymentAmount = $amount;
2669+
2670+
if($amount <= 0) {
2671+
$this->_paymentAmount = $amount;
2672+
}
26692673
}
26702674

26712675
/**

0 commit comments

Comments
 (0)