From ca29640d3fc4247bd24f2db68f0caaf75a4e95cb Mon Sep 17 00:00:00 2001 From: Siarhey Uchukhlebau Date: Mon, 21 Sep 2020 16:24:41 +0300 Subject: [PATCH] Initial commit --- Observer/CheckoutLayoutModifier.php | 58 +++++++++++++++++++ composer.json | 21 +++++++ etc/frontend/events.xml | 14 +++++ etc/module.xml | 15 +++++ registration.php | 11 ++++ view/frontend/requirejs-config.js | 13 +++++ .../frontend/web/js/mixin/time-range-mixin.js | 19 ++++++ view/frontend/web/template/container.html | 11 ++++ view/frontend/web/template/form/field.html | 41 +++++++++++++ 9 files changed, 203 insertions(+) create mode 100644 Observer/CheckoutLayoutModifier.php create mode 100755 composer.json create mode 100644 etc/frontend/events.xml create mode 100755 etc/module.xml create mode 100755 registration.php create mode 100644 view/frontend/requirejs-config.js create mode 100644 view/frontend/web/js/mixin/time-range-mixin.js create mode 100644 view/frontend/web/template/container.html create mode 100644 view/frontend/web/template/form/field.html diff --git a/Observer/CheckoutLayoutModifier.php b/Observer/CheckoutLayoutModifier.php new file mode 100644 index 0000000..d531ed2 --- /dev/null +++ b/Observer/CheckoutLayoutModifier.php @@ -0,0 +1,58 @@ +getSubject(); + /** @var array $jsLayout */ + $jsLayout = &$subject->getJsLayout(); + + $nameInLayout = 'delivery_date'; + // Copy element + $originalElement = $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children'] + ['shippingAddress']['children']['shippingAdditional']['children'][$nameInLayout]; + + // Remove original element from layout + unset( + $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children'] + ['shippingAddress']['children']['shippingAdditional']['children'][$nameInLayout] + ); + + $originalElement['config']['template'] = 'MageWorx_DeliveryDateCheckout/container'; + + // Remove DD comments + unset($originalElement['children']['comment_container']); + + // Update Date component + $originalElement['children']['datetime_container']['children']['delivery_day']['config']['template'] = + 'MageWorx_DeliveryDateCheckout/form/field'; + + // Update Time component + $originalElement['children']['datetime_container']['children']['delivery_time']['config']['template'] = + 'MageWorx_DeliveryDateCheckout/form/field'; + + $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children'] + ['shippingMethods']['children']['shipping_method_additional_data']['children'][$nameInLayout] = + $originalElement; + } +} diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..74b88cd --- /dev/null +++ b/composer.json @@ -0,0 +1,21 @@ +{ + "name": "mageworx/module-deliverydate-checkout-compatibility", + "description": "Delivery Date and MageWorx Checkout Compatibility Extension", + "require": { + "magento/module-ui" : ">=100.1.0 < 102", + "mageworx/module-checkout" : ">=1.0.0", + "mageworx/module-deliverydate" : ">=1.8.6" + }, + "type": "magento2-module", + "version": "1.0.0", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ "registration.php" ], + "psr-4": { + "MageWorx\\DeliveryDateCheckout\\": "" + } + } +} diff --git a/etc/frontend/events.xml b/etc/frontend/events.xml new file mode 100644 index 0000000..3e124b8 --- /dev/null +++ b/etc/frontend/events.xml @@ -0,0 +1,14 @@ + + + + + + + diff --git a/etc/module.xml b/etc/module.xml new file mode 100755 index 0000000..ccc5259 --- /dev/null +++ b/etc/module.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/registration.php b/registration.php new file mode 100755 index 0000000..6c8cb43 --- /dev/null +++ b/registration.php @@ -0,0 +1,11 @@ + +
+ + + +
diff --git a/view/frontend/web/template/form/field.html b/view/frontend/web/template/form/field.html new file mode 100644 index 0000000..8c620e4 --- /dev/null +++ b/view/frontend/web/template/form/field.html @@ -0,0 +1,41 @@ +
+
+ + + + +
+ + + + +
+ + + + + +
+