'Delivery Dates Wizard Pro', // One name for all langs 'class_name' => 'DDWAdmin', 'visible' => true ) ); public function __construct() { $this->name = 'deliverydateswizardpro'; $this->tab = 'checkout'; $this->version = '2.2.3'; $this->author = 'Musaffar Patel'; parent::__construct(); $this->displayName = $this->l('Delivery Dates Wizard Pro'); $this->description = $this->l('Allow customers to conveniently select a delivery date during checkout'); $this->module_key = '893c65fda54d76f42ec334089fdd1963'; $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); $this->file = __FILE__; $this->bootstrap = true; $this->base_url = Tools::getShopProtocol() . Tools::getShopDomain() . __PS_BASE_URI__; $this->ps_versions_compliancy = array('min' => '1.7.0.0', 'max' => _PS_VERSION_); /* Initialise controllers */ $this->controller_front = new DDWFrontCheckoutController($this); $this->controller_config = new DDWConfigController($this); $this->controller_config_carrier = new DDWConfigCarrierController($this); $this->ddw_producttab_controller = new DDWProductTabController($this); } public function install() { if (!parent::install() || !$this->registerHook('header') || !$this->registerHook('actionCarrierProcess') || !$this->registerHook('beforeCarrier') || !$this->registerHook('displayAfterCarrier') || !$this->registerHook('adminOrder') || !$this->registerHook('backOfficeHeader') || !$this->registerHook('paymentConfirm') || !$this->registerHook('newOrder') || !$this->registerHook('PDFInvoice') || !$this->registerHook('DdwValidateOrder') || !$this->registerHook('actionOrderDetail') || !$this->registerHook('displayPDFInvoice') || !$this->registerHook('displayCarrierList') || !$this->registerHook('displayPDFDeliverySlip') || !$this->registerHook('displayOrderDetail') || !$this->registerHook('actionCarrierUpdate') || !$this->registerHook('displayAdminProductsExtra') || !$this->registerHook('displayProductButtons') || !$this->registerHook('displayOrderConfirmation') || !$this->registerHook('getEmailTemplateVars') || !$this->registerHook('actionDispatcher') || !$this->registerHook('actionOrderGridDefinitionModifier') || !$this->registerHook('actionOrderGridQueryBuilderModifier') || !$this->registerHook('displayAdminOrderTabContent') || !$this->installModule()) { return false; } else { return true; } } private function installModule() { DDWInstall::installDB(); DDWInstall::installData(); return true; } public function uninstall() { DDWInstall::uninstall(); parent::uninstall(); return true; } /* Call set media for all the various controllers in this module. Each controller will decide if the time is appropriate for queuing it's css and js */ public function setMedia() { (new DDWConfigGeneralController($this))->setMedia(); (new DDWFrontCheckoutController($this))->setMedia(); (new DDWProductTabController($this))->setMedia(); } public function getContent() { return $this->route(); } /* Store Hooks */ public function hookDisplayAdminProductsExtra($params) { $ddw_producttab_controller = new DDWProductTabController($this, $params); return $ddw_producttab_controller->route(); } public function hookActionCarrierProcess($params) { $this->controller_front->hookActionCarrierProcess($params); } /** * render the widget during checkout * @param $params * @return mixed */ public function hookDisplayAfterCarrier($params) { $ddw_front_checkout_controller = new DDWFrontCheckoutController($this); return $ddw_front_checkout_controller->renderFrontWidget($params); } /** * Display on the order details page in customer account * @param $params * @return string */ public function hookDisplayOrderDetail($params) { $ddw_front_controller = new DDWFrontCheckoutController($this); return $ddw_front_controller->hookDisplayOrderDetail($params); } /** * Called automatically when editing an order and can be called manually /adminps/themes/default/template/controllers/orders/form.tpl * @param $params * @return mixed */ public function hookAdminOrder($params) { if (!empty($params['id_order'])) { $id_order = $params['id_order']; } else { $id_order = 0; } $ddw_admin_order_controller = new DDWAdminOrderController($this); return $ddw_admin_order_controller->renderOrderDetailBlock($id_order); } public function hookDisplayPDFInvoice($params) { $ddw_admin_order_controller = new DDWAdminOrderController($this); return $ddw_admin_order_controller->renderHookDisplayPDFInvoice($params); } /** * Display delivery date and time in delivery slip * @param $params * @return string|void */ public function hookDisplayPDFDeliverySlip($params) { $ddw_admin_order_controller = new DDWAdminOrderController($this); return $ddw_admin_order_controller->renderHookDisplayPDFDeliverySlip($params); } public function hookDdwValidateOrder($params) { $ddw_datetime = DDWCartHelper::getCartDDWDateTime($params['id_cart']); return $ddw_datetime; } /** * Get delivery date and time for when emails are sent */ public function hookGetEmailTemplateVars($params) { $params = DDWTemplateHookHelper::getEmailTemplateVars($params); } /** * Called when an order is updated or created * @param $params * @return bool|void */ public function hookNewOrder($params) { if (Tools::getValue('submitAddorder') == '1' && (int)$params['order']->id > 0) { //DDW::saveToCart(Tools::getValue('ddw_order_date'), Tools::getValue('ddw_order_time'), $id_cart); DDWModel::saveToOrderDirect($params['order']->id, Tools::getValue('ddw_order_date'), Tools::getValue('ddw_order_time')); return; } $cart = $params['cart']; if (!($cart instanceof Cart)) { return; } DDWModel::saveToOrder($cart); } public function hookHeader($params) { $this->setMedia(); } public function hookBackOfficeHeader($params) { $this->setMedia(); } public function hookActionCarrierUpdate($params) { DDWModel::updateCarrierID($params['id_carrier'], $params['carrier']->id); } public function hookDisplayProductButtons($params) { $ddw_front_product_controller = new DDWFrontProductController($this); return $ddw_front_product_controller->renderETA(Tools::getValue('id_product'), $params); } public function hookDisplayOrderConfirmation($params) { $ddw_front_controller = new DDWFrontCheckoutController($this); return $ddw_front_controller->hookDisplayOrderConfirmation($params); } /** * Set referral link when landing one site if we need to * @param $params * @throws Exception */ public function hookActionDispatcher($params) { (new DDWFrontCheckoutController($this))->hookActionDispatcher($params); } /** * Hook allows to modify order list grid definition. Prestashnop 1.7.7.x * @param array $params # */ public function hookActionOrderGridDefinitionModifier(array $params) { (new DDWAdminOrderController($this))->hookActionOrderGridDefinitionModifier($params); } /** * Hook allows to modify orders list query builder and add custom sql statements. * @param array $params */ public function hookActionOrderGridQueryBuilderModifier(array $params) { (new DDWAdminOrderController($this))->hookActionOrderGridQueryBuilderModifier($params); } /** * Display delivery date in order view page (Available since 1.7.7.0) * @param $params * @return string */ public function hookDisplayAdminOrderTabContent($params) { return (new DDWAdminOrderController($this))->renderOrderDetailBlock($params); } /** * route to controller * @return string|void */ public function route() { $render = ''; switch (Tools::getValue('section')) { case 'adminproducttab': $ddw_admin_tab_general_controller = new DDWAdminTabGeneralController($this, $_POST); die($ddw_admin_tab_general_controller->route()); } switch (Tools::getValue('route')) { case 'ddwadminconfiggeneral': $ddw_general = new DDWConfigGeneralController($this); $render .= $ddw_general->route(); break; case 'ddwadminconfigweekdays': $ddw_weekdays = new DDWConfigWeekdaysController($this); die($ddw_weekdays->route()); case 'ddwadminconfigspecificdates': $ddw_specificdates = new DDWConfigSpecificDatesController($this); die($ddw_specificdates->route()); case 'ddwadminconfigblockeddates': $ddw_blockedates = new DDWConfigBlockedDatesController($this); die($ddw_blockedates->route()); case 'ddwconfigtranslations': $ddw_translations = new DDWConfigTranslationsController($this); return $ddw_translations->route(); case 'ddwadminconfigproducts': $ddw_products = new DDWConfigProductController($this); return $ddw_products->route(); case 'ddwadminconfigdistance': $ddw_distance_controller = new DDWConfigDistanceController($this); return $ddw_distance_controller->route(); case 'ddwconfigdeliverymanagercontroller': $ddw_delivery_manager_controller = new DDWConfigDeliveryManagerController($this); return $ddw_delivery_manager_controller->route(); case DDWFrontCheckoutController::$route: $ddw_front_checkout_controller = new DDWFrontCheckoutController($this); return $ddw_front_checkout_controller->route(); } if (Tools::getIsset('updatecarriers')) { return $this->controller_config_carrier->route(); } else { return $this->controller_config->renderMain(); } return $render; } }