From f815b2702ce6317d84049ac41dd794d57789f956 Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Fri, 30 Aug 2024 12:06:45 +0200 Subject: [PATCH 1/3] Fix issues with logged in customers without saved address #113 --- .../web/js/checkout/action/set-shipping-information-mixin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/frontend/web/js/checkout/action/set-shipping-information-mixin.js b/view/frontend/web/js/checkout/action/set-shipping-information-mixin.js index 53ce257..a2386d7 100755 --- a/view/frontend/web/js/checkout/action/set-shipping-information-mixin.js +++ b/view/frontend/web/js/checkout/action/set-shipping-information-mixin.js @@ -55,7 +55,7 @@ define([ const shippingAddress = quote.billingAddress(); let currentAddress; - if (isCustomerLogin) { + if (isCustomerLogin && Object.keys(window.checkoutConfig.customerData.addresses).length > 0) { currentAddress = selectedShippingAddress === 'new-customer-address' ? customerData.get('checkout-data')().shippingAddressFromData : window.checkoutConfig.customerData.addresses[getAddressId()]; From 2794e23abcb8241a75286f312cfabc5197aee24f Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Fri, 30 Aug 2024 12:34:54 +0200 Subject: [PATCH 2/3] Return null on insurance when empty value is added though config --- Model/Config.php | 10 +++++++--- Test/Unit/Model/Api/Builder/OrderTest.php | 4 ++-- etc/adminhtml/system.xml | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Model/Config.php b/Model/Config.php index 617050f..966554f 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -564,11 +564,15 @@ public function showWidgetOnFirstLoad($store = null) /** * @param null|Store|int|string $store - * @return float + * @return float|null */ - public function getInsuranceValue($store = null) + public function getInsuranceValue($store = null): ?float { - return abs((float)$this->getValue(self::API_CONFIG_PATH . '/insurance_value', $store)); + $value = $this->getValue(self::API_CONFIG_PATH . '/insurance_value', $store); + if ($value === null || $value === '') { + return null; + } + return abs((float)$value); } /** diff --git a/Test/Unit/Model/Api/Builder/OrderTest.php b/Test/Unit/Model/Api/Builder/OrderTest.php index c55e51d..795fd71 100644 --- a/Test/Unit/Model/Api/Builder/OrderTest.php +++ b/Test/Unit/Model/Api/Builder/OrderTest.php @@ -275,8 +275,8 @@ public function testOrderInsuredValue($configValue, $orderCurrency) public function orderInsuredValueDataProvider() { return [ - [0, 'EUR'], - [0, 'USD'], + [null, 'EUR'], + [null, 'USD'], [1.05, 'EUR'], [20.19, 'USD'], [201.36363, 'USD'], diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 5e7e023..fd0c773 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -164,7 +164,7 @@ 1 - Fill in the insurance amount as a number. + Fill in the insurance amount as a number. Null will be added if the value is empty. From f37c0f4714e9d06cfc162fb1760612e8ab4adbd0 Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Fri, 30 Aug 2024 12:35:02 +0200 Subject: [PATCH 3/3] Version bump --- composer.json | 2 +- etc/config.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 91799ec..aab7f72 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "paazl/magento2-checkout-widget", "description": "Paazl checkoutWidget for Magento 2", "type": "magento2-module", - "version": "1.17.1", + "version": "1.17.2", "keywords": [ "Paazl", "Magento 2", diff --git a/etc/config.xml b/etc/config.xml index dc5a394..f42d708 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -8,7 +8,7 @@ - v1.17.1 + v1.17.2 0 0 0