From 4d2efcdeae86ea3dea54fb9e02a8e94d2c9ea176 Mon Sep 17 00:00:00 2001 From: Joel Male Date: Tue, 3 Sep 2024 21:07:58 +1000 Subject: [PATCH] fix tests for cart conditions --- .github/workflows/tests.yml | 2 +- src/Cart.php | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3ba70c4..dcf99be 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: true matrix: - php: ['8.1','8.2', '8.3'] + php: ['8.0', '8.1','8.2', '8.3', '8.4'] stability: [prefer-stable] steps: diff --git a/src/Cart.php b/src/Cart.php index c3147b0..435211c 100644 --- a/src/Cart.php +++ b/src/Cart.php @@ -345,17 +345,13 @@ public function getConditions(bool $active = false): CartConditionCollection if ($active) { return $conditions->filter(function (CartCondition $condition) { - $target = $condition->getTarget(); + $amount = $condition->getTarget() == 'subtotal' ? $this->getSubTotal(false) : $this->getTotal(); - $amount = $target == 'subtotal' ? $this->getSubTotal(false) : $this->getTotal(); - - return $condition->getMinimum() <= $amount; + return $condition->getMinimum() === null || $condition->getMinimum() <= $amount; })->filter(function (CartCondition $condition) { - $target = $condition->getTarget(); + $amount = $condition->getTarget() == 'subtotal' ? $this->getSubTotal(false) : $this->getTotal(); - $amount = $target == 'subtotal' ? $this->getSubTotal(false) : $this->getTotal(); - - return $condition->getMaximum() >= $amount; + return $condition->getMaximum() === null || $condition->getMaximum() >= $amount; }); }