diff --git a/dpdbaltics.php b/dpdbaltics.php index e22b385..d128d0b 100644 --- a/dpdbaltics.php +++ b/dpdbaltics.php @@ -168,7 +168,7 @@ public function getModuleContainer($id = false) public function hookActionFrontControllerSetMedia() { //TODO fillup this array when more modules are compatible with OPC - $onePageCheckoutControllers = ['supercheckout']; + $onePageCheckoutControllers = ['supercheckout', 'onepagecheckoutps']; $applicableControlelrs = ['order', 'order-opc', 'ShipmentReturn', 'supercheckout']; $currentController = !empty($this->context->controller->php_self) ? $this->context->controller->php_self : Tools::getValue('controller'); @@ -183,7 +183,9 @@ public function hookActionFrontControllerSetMedia() ); } - if (in_array($currentController, $onePageCheckoutControllers, true)) { + //todo for onepagecheckoutps module these are needed to be included as it handles phone number + // onepageps module controller is like in normal prestashop OrderController and some test are needed with normal flow +// if (in_array($currentController, $onePageCheckoutControllers, true)) { $this->context->controller->addJqueryPlugin('chosen'); $this->context->controller->registerJavascript( @@ -204,7 +206,7 @@ public function hookActionFrontControllerSetMedia() ] ); - } +// } /** @var \Invertus\dpdBaltics\Provider\CurrentCountryProvider $currentCountryProvider */ $currentCountryProvider = $this->getModuleContainer('invertus.dpdbaltics.provider.current_country_provider'); @@ -348,21 +350,23 @@ public function hookActionValidateStepComplete(&$params) return; } } - if (!Tools::getValue('dpd-phone')) { - $this->context->controller->errors[] = - $this->l('In order to use DPD Carrier you need to enter phone number'); - $params['completed'] = false; - - return; - } - if (!Tools::getValue('dpd-phone-area')) { - $this->context->controller->errors[] = - $this->l('In order to use DPD Carrier you need to enter phone area'); - $params['completed'] = false; - - return; - } + // todo thecheckout module triggers this hook when submiting the payment form +// if (!Tools::getValue('dpd-phone')) { +// $this->context->controller->errors[] = +// $this->l('In order to use DPD Carrier you need to enter phone number'); +// $params['completed'] = false; +// +// return; +// } +// +// if (!Tools::getValue('dpd-phone-area')) { +// $this->context->controller->errors[] = +// $this->l('In order to use DPD Carrier you need to enter phone area'); +// $params['completed'] = false; +// +// return; +// } /** @var CarrierPhoneService $carrierPhoneService */ $carrierPhoneService = $this->getModuleContainer()->get('invertus.dpdbaltics.service.carrier_phone_service'); diff --git a/views/js/front/order-opc.js b/views/js/front/order-opc.js index 3306592..2b05e7b 100644 --- a/views/js/front/order-opc.js +++ b/views/js/front/order-opc.js @@ -24,6 +24,18 @@ $(document).ready(function (){ handlePhoneNumber($(this)); }); + // todo need event listener to trigger the checkout form and handle phone number + $('body').on('click', '#confirm_order', function(e) { + e.preventDefault(); + + if ($('.dpd-phone-block') !== undefined) { + if(!handlePhoneNumber($('.dpd-phone-block'))) { + return; + } + } + + }); + $(document).on('click','.payment_module a', function (e){ e.preventDefault(); @@ -82,3 +94,9 @@ function DPDdisplayMessageOpc(parent, template) { var $messageContainer = parent.find('.dpd-message-container'); $messageContainer.html(template); } + +// Module "onepagecheckoutps" compatibility +$(document).on('opc-load-review:completed', function() { + $('.delivery-option.selected .carrier-extra-content').show(); +}); +