From 94dd13e84ba2622499dbb081d90ee15dd634110a Mon Sep 17 00:00:00 2001 From: Luke Holder Date: Wed, 18 Oct 2023 11:36:32 +0800 Subject: [PATCH 1/3] Fixes #3279 --- CHANGELOG.md | 1 + src/adjusters/Shipping.php | 4 ++-- src/base/ShippingMethod.php | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f04b1e806..179b0557f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Fixed an XSS vulnerability. - Fixed a bug where emails were not being ordered by name correctly. ([#3263](https://github.com/craftcms/commerce/issues/3263)) - Fixed a bug where a gateway’s webhook URL was malformed. ([#3299](https://github.com/craftcms/commerce/issues/3299)) +- The order param is now included when triggering the `craft\commerce\services\Purchasables::EVENT_PURCHASABLE_SHIPPABLE` event. ([#3279](https://github.com/craftcms/commerce/pull/3279)) ## 3.4.22.1 - 2023-06-03 diff --git a/src/adjusters/Shipping.php b/src/adjusters/Shipping.php index e3280f7f54..a96b60fad4 100644 --- a/src/adjusters/Shipping.php +++ b/src/adjusters/Shipping.php @@ -64,7 +64,7 @@ public function adjust(Order $order): array foreach ($lineItems as $item) { $purchasable = $item->getPurchasable(); - if ($purchasable && !Plugin::getInstance()->getPurchasables()->isPurchasableShippable($purchasable)) { + if ($purchasable && !Plugin::getInstance()->getPurchasables()->isPurchasableShippable($purchasable, $order)) { $nonShippableItems[$item->id] = $item->id; } } @@ -125,7 +125,7 @@ public function adjust(Order $order): array } $freeShippingFlagOnProduct = $item->purchasable->hasFreeShipping(); - $shippable = Plugin::getInstance()->getPurchasables()->isPurchasableShippable($item->getPurchasable()); + $shippable = Plugin::getInstance()->getPurchasables()->isPurchasableShippable($item->getPurchasable(), $order); if (!$freeShippingFlagOnProduct && !$hasFreeShippingFromDiscount && $shippable) { $adjustment = $this->_createAdjustment($shippingMethod, $rule); diff --git a/src/base/ShippingMethod.php b/src/base/ShippingMethod.php index e57c6b7668..6b251f49f0 100644 --- a/src/base/ShippingMethod.php +++ b/src/base/ShippingMethod.php @@ -162,7 +162,7 @@ public function getPriceForOrder(Order $order) foreach ($lineItems as $item) { $purchasable = $item->getPurchasable(); - if ($purchasable && !Plugin::getInstance()->getPurchasables()->isPurchasableShippable($purchasable)) { + if ($purchasable && !Plugin::getInstance()->getPurchasables()->isPurchasableShippable($purchasable, $order)) { $nonShippableItems[$item->id] = $item->id; } } @@ -175,7 +175,7 @@ public function getPriceForOrder(Order $order) $amount = $shippingRule->getBaseRate(); foreach ($order->lineItems as $item) { - if ($item->getPurchasable() && !$item->purchasable->hasFreeShipping() && Plugin::getInstance()->getPurchasables()->isPurchasableShippable($item->getPurchasable())) { + if ($item->getPurchasable() && !$item->purchasable->hasFreeShipping() && Plugin::getInstance()->getPurchasables()->isPurchasableShippable($item->getPurchasable(), $order)) { $percentageRate = $shippingRule->getPercentageRate($item->shippingCategoryId); $perItemRate = $shippingRule->getPerItemRate($item->shippingCategoryId); $weightRate = $shippingRule->getWeightRate($item->shippingCategoryId); From fc7be6ec00aa33be8666a276653677340c8fa06d Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Wed, 18 Oct 2023 09:43:09 -0700 Subject: [PATCH 2/3] Changelog tweaks --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 179b0557f2..b490a02b4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,10 @@ ## Unreleased +- `craft\commerce\services\Purchasables::EVENT_PURCHASABLE_SHIPPABLE` event handlers can now access the order. ([#3279](https://github.com/craftcms/commerce/pull/3279)) +- Fixed a SQL error that could occur when fetching emails. ([#3267](https://github.com/craftcms/commerce/pull/3267)) +- Fixed a bug where gateway URLs could be malformed. ([#3299](https://github.com/craftcms/commerce/issues/3299)) - Fixed an XSS vulnerability. -- Fixed a bug where emails were not being ordered by name correctly. ([#3263](https://github.com/craftcms/commerce/issues/3263)) -- Fixed a bug where a gateway’s webhook URL was malformed. ([#3299](https://github.com/craftcms/commerce/issues/3299)) -- The order param is now included when triggering the `craft\commerce\services\Purchasables::EVENT_PURCHASABLE_SHIPPABLE` event. ([#3279](https://github.com/craftcms/commerce/pull/3279)) ## 3.4.22.1 - 2023-06-03 From bc11b8a3db4584b60438b5dfdff028433afeb52f Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Wed, 18 Oct 2023 18:17:09 +0100 Subject: [PATCH 3/3] Finish 3.4.23 --- CHANGELOG.md | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b490a02b4b..daac66dedd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Release Notes for Craft Commerce -## Unreleased +## 3.4.23 - 2023-10-18 - `craft\commerce\services\Purchasables::EVENT_PURCHASABLE_SHIPPABLE` event handlers can now access the order. ([#3279](https://github.com/craftcms/commerce/pull/3279)) - Fixed a SQL error that could occur when fetching emails. ([#3267](https://github.com/craftcms/commerce/pull/3267)) diff --git a/composer.json b/composer.json index b0180cbcf9..e98782d365 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ }, "extra": { "handle": "commerce", - "version": "3.4.22.1", + "version": "3.4.23", "name": "Craft Commerce", "description": "Create beautifully bespoke ecommerce experiences", "developer": "Pixel & Tonic",