From 70669ebca9ffe22747cf0e7bfa48392aa37aefdb Mon Sep 17 00:00:00 2001 From: Rakhal Imming Date: Mon, 12 Feb 2024 11:50:32 +0100 Subject: [PATCH] Added configurable option to default select first service point --- Model/Carrier.php | 4 +++- etc/adminhtml/system.xml | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Model/Carrier.php b/Model/Carrier.php index b823ddd..abf08e3 100644 --- a/Model/Carrier.php +++ b/Model/Carrier.php @@ -317,7 +317,9 @@ protected function getMethodTitle(\Magento\Quote\Model\Quote\Address\RateRequest } // Select default servicePoint if none is selected - if (!$servicePointId) { + $selectFirstByDefault = $this->getConfigData('shipping_methods/servicepoint/default_select_first'); + + if (!$servicePointId && $selectFirstByDefault) { $toCountry = $request->getDestCountryId(); $toPostalCode = $request->getDestPostcode(); $servicePoint = $this->servicePointService->getClosest($toPostalCode, $toCountry); diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index c86bbed..d47bd6a 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -738,6 +738,15 @@ Leave empty to use default title + + + Magento\Config\Model\Config\Source\Yesno + By enabling this option, if the customer is not selecting a service point, the most closeby service point will be selected. + + 1 + +