From 9373a09e0db289a9312233a945604aaeffd9a2f1 Mon Sep 17 00:00:00 2001 From: stormbyte Date: Tue, 8 Nov 2022 08:53:42 +0100 Subject: [PATCH 1/4] `fetchCheckoutData response status` should return `$status` --- Model/Api/PaazlApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Api/PaazlApi.php b/Model/Api/PaazlApi.php index de24ed3..844ac2e 100644 --- a/Model/Api/PaazlApi.php +++ b/Model/Api/PaazlApi.php @@ -217,7 +217,7 @@ public function fetchCheckoutData($reference) $httpClient->get($url); $status = $httpClient->getStatus(); $body = $httpClient->getBody(); - $this->generalHelper->addTolog('fetchCheckoutData response status: ', $body); + $this->generalHelper->addTolog('fetchCheckoutData response status: ', $status); $this->generalHelper->addTolog('fetchCheckoutData response: ', $body); } catch (Exception $e) { $this->generalHelper->addTolog('exception', $e->getMessage()); From 8ee6e17e80a6c246a4b781dfd2aaed40a566a58d Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Thu, 16 Feb 2023 14:33:07 +0100 Subject: [PATCH 2/4] Added Estimated Delivery Range --- .../Api/Converter/Checkout/ToShippingInfo.php | 1 + Model/ShippingInfo.php | 18 ++++++++++++++++++ .../paazl-status.phtml | 16 ++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/Model/Api/Converter/Checkout/ToShippingInfo.php b/Model/Api/Converter/Checkout/ToShippingInfo.php index 6528961..cf9b385 100644 --- a/Model/Api/Converter/Checkout/ToShippingInfo.php +++ b/Model/Api/Converter/Checkout/ToShippingInfo.php @@ -74,6 +74,7 @@ public function convert($response) $info->setPrice(floatval($this->arrayManager->get('shippingOption/rate', $result))); $info->setOptionTitle($this->arrayManager->get('shippingOption/name', $result)); $info->setPreferredDeliveryDate($this->arrayManager->get('preferredDeliveryDate', $result)); + $info->setEstimatedDeliveryRange($this->arrayManager->get('shippingOption/estimatedDeliveryRange', $result)); $info->setCarrierPickupDate($this->arrayManager->get('pickupDate', $result)); if ($info->getType() === DeliveryType::PICKUP) { diff --git a/Model/ShippingInfo.php b/Model/ShippingInfo.php index ce0efb2..dd97e06 100644 --- a/Model/ShippingInfo.php +++ b/Model/ShippingInfo.php @@ -31,6 +31,7 @@ class ShippingInfo extends DataObject public const OPTION_TITLE = 'option_title'; public const ADDRESS = 'address'; public const PREFERRED_DELIVERY_DATE = 'preferred_delivery_date'; + public const ESTIMATED_DELIVERY_RANGE = 'estimated_delivery_range'; public const CARRIER_PICKUP_DATE = 'carrier_pickup_date'; /**#@- */ @@ -240,6 +241,23 @@ public function getPreferredDeliveryDate() return $this->getData(self::PREFERRED_DELIVERY_DATE); } + /** + * @param string $value + * @return $this + */ + public function setEstimatedDeliveryRange($value) + { + return $this->setData(self::ESTIMATED_DELIVERY_RANGE, $value); + } + + /** + * @return string|null + */ + public function getEstimatedDeliveryRange() + { + return $this->getData(self::ESTIMATED_DELIVERY_RANGE); + } + /** * @param string $value * @return $this diff --git a/view/adminhtml/templates/order/view/shipping-and-handling-info/paazl-status.phtml b/view/adminhtml/templates/order/view/shipping-and-handling-info/paazl-status.phtml index e932d5b..51bff15 100644 --- a/view/adminhtml/templates/order/view/shipping-and-handling-info/paazl-status.phtml +++ b/view/adminhtml/templates/order/view/shipping-and-handling-info/paazl-status.phtml @@ -43,12 +43,28 @@ use Paazl\CheckoutWidget\Ui\Component\Order\Listing\Column\Status\Options; + getEstimatedDeliveryRange()) : ?> + + : + + + + : + + + getCarrierPickupDate()) : ?> : + + + : + + + From c86b9ad88abbe69ee61e1a17688c4822143b5a1b Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Thu, 16 Feb 2023 14:37:43 +0100 Subject: [PATCH 3/4] Added option to enable / disable automatically pushing orders --- Cron/SendOrders.php | 26 ++++++++++---- Model/Config.php | 10 ++++++ Model/System/Config/Source/SyncMethod.php | 41 +++++++++++++++++++++++ etc/adminhtml/system.xml | 5 +++ etc/config.xml | 1 + 5 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 Model/System/Config/Source/SyncMethod.php diff --git a/Cron/SendOrders.php b/Cron/SendOrders.php index 508c769..796718b 100755 --- a/Cron/SendOrders.php +++ b/Cron/SendOrders.php @@ -7,12 +7,14 @@ namespace Paazl\CheckoutWidget\Cron; use Exception; -use Zend_Db_Expr; use Magento\Sales\Model\ResourceModel\Order\Collection\Factory; use Magento\Sales\Model\ResourceModel\Order\CollectionFactory; +use Paazl\CheckoutWidget\Helper\General as GeneralHelper; use Paazl\CheckoutWidget\Model\Api\Processor\SendToService; +use Paazl\CheckoutWidget\Model\Config; use Paazl\CheckoutWidget\Model\ResourceModel\Order\OrderReference; -use Paazl\CheckoutWidget\Helper\General as GeneralHelper; +use Paazl\CheckoutWidget\Model\System\Config\Source\SyncMethod; +use Zend_Db_Expr; /** * Class SendOrders @@ -42,21 +44,29 @@ class SendOrders */ private $generalHelper; + /** + * @var Config + */ + private $config; + /** * SendOrders constructor. * - * @param SendToService $sendToService + * @param SendToService $sendToService * @param CollectionFactory $orderCollectionFactory - * @param GeneralHelper $generalHelper + * @param GeneralHelper $generalHelper + * @param Config $config */ public function __construct( SendToService $sendToService, CollectionFactory $orderCollectionFactory, - GeneralHelper $generalHelper + GeneralHelper $generalHelper, + Config $config ) { $this->sendToService = $sendToService; $this->orderCollectionFactory = $orderCollectionFactory; $this->generalHelper = $generalHelper; + $this->config = $config; } /** @@ -64,7 +74,9 @@ public function __construct( */ public function execute() { - $messages = []; + if ($this->config->getSyncMethod() != SyncMethod::SYNC_METHOD_CRON) { + return []; + } $collection = $this->orderCollectionFactory->create(); $collection->getSelect() @@ -86,6 +98,6 @@ public function execute() } } - return $messages; + return []; } } diff --git a/Model/Config.php b/Model/Config.php index 984e577..1b9fd53 100644 --- a/Model/Config.php +++ b/Model/Config.php @@ -120,6 +120,16 @@ public function getApiMode($store = null) return (int)$mode; } + /** + * @param null|Store|int|string $store + * + * @return int + */ + public function getSyncMethod($store = null): int + { + return (int)$this->getValue(self::API_CONFIG_PATH . '/sync_method', $store); + } + /** * @param null|Store|int|string $store * diff --git a/Model/System/Config/Source/SyncMethod.php b/Model/System/Config/Source/SyncMethod.php new file mode 100644 index 0000000..f4e1174 --- /dev/null +++ b/Model/System/Config/Source/SyncMethod.php @@ -0,0 +1,41 @@ +options) { + $this->options = [ + ['value' => self::SYNC_METHOD_CRON, 'label' => __('Cron')], + ['value' => self::SYNC_METHOD_MANUAL, 'label' => __('Manual')] + ]; + } + + return $this->options; + } +} diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 7e4555d..c802c9c 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -242,6 +242,11 @@ Paazl\CheckoutWidget\Block\Adminhtml\Paazl\Heading + + + Paazl\CheckoutWidget\Model\System\Config\Source\SyncMethod + Choose method to push orders to API. + Time threshold in seconds after which API is treated as not responding. diff --git a/etc/config.xml b/etc/config.xml index 77e0459..0a889d2 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -14,6 +14,7 @@ 0 + 0 300 Paazl\CheckoutWidget\Model\Carrier\Paazlshipping Paazl From 188439cbf56c7438a4cc8318ff98c2296ce295b8 Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Thu, 16 Feb 2023 14:38:29 +0100 Subject: [PATCH 4/4] 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 ce56c75..c4275a4 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.13.0", + "version": "1.14.0", "keywords": [ "Paazl", "Magento 2", diff --git a/etc/config.xml b/etc/config.xml index 0a889d2..2fb3117 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -8,7 +8,7 @@ - v1.13.0 + v1.14.0 0 0 0