From a520063667121d6c556642e151869fdad6f4a8d3 Mon Sep 17 00:00:00 2001 From: Andrii Date: Fri, 16 Feb 2024 13:48:06 +0200 Subject: [PATCH] Added option for 'unspecified' delivery type (#80) Co-authored-by: Andrii --- Api/Data/ShippingMethodInterface.php | 5 +++++ CHANGELOG.md | 3 +++ Helper/Config.php | 19 +++++++++++++++++++ Model/Api/Client.php | 2 +- Model/ShippingCallback.php | 11 +++++++++-- Model/Source/Carrier.php | 2 -- composer.json | 2 +- etc/adminhtml/system.xml | 8 +++++++- etc/module.xml | 2 +- 9 files changed, 46 insertions(+), 8 deletions(-) diff --git a/Api/Data/ShippingMethodInterface.php b/Api/Data/ShippingMethodInterface.php index b8002cd..2aa941c 100644 --- a/Api/Data/ShippingMethodInterface.php +++ b/Api/Data/ShippingMethodInterface.php @@ -19,6 +19,11 @@ interface ShippingMethodInterface */ const DELIVERY_METHOD_PICKUP = 'pick_up'; + /* + * Unspecified + */ + const DELIVERY_METHOD_UNSPECIFIED = 'unspecified'; + /* * None */ diff --git a/CHANGELOG.md b/CHANGELOG.md index fec2fcb..9f29ef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +v1.7.14 +- Added option to allow selection of 'unspecified' delivery method + v1.7.13 - Session update logic when coupon code changes re-worked. diff --git a/Helper/Config.php b/Helper/Config.php index 4a0edac..e42f366 100644 --- a/Helper/Config.php +++ b/Helper/Config.php @@ -105,6 +105,11 @@ class Config extends AbstractHelper */ const XPATH_PICKUP_METHODS = 'payment/dintero/shipping_methods_map'; + /* + * Shipping methods map + */ + const XPATH_UNSPECIFIED_METHODS = 'payment/dintero/unspecified_methods_map'; + /* * Default callback delay in seconds */ @@ -604,4 +609,18 @@ public function getPickupMethods($scopeCode = null) $this->scopeConfig->getValue(self::XPATH_PICKUP_METHODS, ScopeInterface::SCOPE_STORE, $scopeCode) ); } + + /** + * Retrieve pickup methods list + * + * @param string $scopeCode + * @return array + */ + public function getUnspecifiedMethods($scopeCode = null) + { + return explode( + ',', + $this->scopeConfig->getValue(self::XPATH_UNSPECIFIED_METHODS, ScopeInterface::SCOPE_STORE, $scopeCode) + ); + } } diff --git a/Model/Api/Client.php b/Model/Api/Client.php index 60f9031..f27d500 100644 --- a/Model/Api/Client.php +++ b/Model/Api/Client.php @@ -254,7 +254,7 @@ private function initRequest($endpoint, $token = null) 'Dintero-System-Name' => __('Magento'), 'Dintero-System-Version' => $this->getSystemMeta()->getVersion(), 'Dintero-System-Plugin-Name' => 'Dintero.Checkout.Magento.V2', - 'Dintero-System-Plugin-Version' => '1.7.13', + 'Dintero-System-Plugin-Version' => '1.7.14', ]; if ($token && $token instanceof Token) { diff --git a/Model/ShippingCallback.php b/Model/ShippingCallback.php index ef6b31c..b19cfcf 100644 --- a/Model/ShippingCallback.php +++ b/Model/ShippingCallback.php @@ -167,8 +167,15 @@ public function __construct( */ protected function resolveDeliveryType($shippingMethod, $scopeCode = null) { - return in_array($shippingMethod, $this->configHelper->getPickupMethods($scopeCode)) - ? ShippingMethodInterface::DELIVERY_METHOD_PICKUP : ShippingMethodInterface::DELIVERY_METHOD_DELIVERY; + if(in_array($shippingMethod, $this->configHelper->getPickupMethods($scopeCode))) { + return ShippingMethodInterface::DELIVERY_METHOD_PICKUP; + } + + if (in_array($shippingMethod, $this->configHelper->getUnspecifiedMethods($scopeCode))) { + return ShippingMethodInterface::DELIVERY_METHOD_UNSPECIFIED; + } + + return ShippingMethodInterface::DELIVERY_METHOD_DELIVERY; } /** diff --git a/Model/Source/Carrier.php b/Model/Source/Carrier.php index 0d977c9..9970779 100644 --- a/Model/Source/Carrier.php +++ b/Model/Source/Carrier.php @@ -52,8 +52,6 @@ public function toOptionArray() continue; } - - $options[] = [ 'label' => $carrier->getConfigData('title'), 'value' => $carrier->getCarrierCode(), diff --git a/composer.json b/composer.json index 357f202..7c2df2a 100644 --- a/composer.json +++ b/composer.json @@ -29,5 +29,5 @@ "Dintero\\Checkout\\": "" } }, - "version": "1.7.13" + "version": "1.7.14" } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 0d5e524..46274cc 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -95,8 +95,14 @@ Dintero\Checkout\Model\Source\Carrier + 1 - + + + Dintero\Checkout\Model\Source\Carrier + 1 + + Magento\Config\Model\Config\Source\Yesno 1 diff --git a/etc/module.xml b/etc/module.xml index bd10ee9..9e17ff5 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - +