name = 'customfields'; $this->tab = 'front_office_features'; $this->version = '2.2.0'; $this->author = 'FMM Modules'; $this->bootstrap = true; $this->module_key = 'cd34d56e2bc861010705859b1c14a5b5'; $this->author_address = '0xcC5e76A6182fa47eD831E43d80Cd0985a14BB095'; parent::__construct(); $this->description = $this->l('This module allows to add custom fields during checkout.'); $this->displayName = $this->l('Custom Fields'); if ($this->id_shop === null || !Shop::isFeatureActive()) { $this->id_shop = Shop::getContextShopID(); } else { $this->id_shop = $this->context->shop->id; } if ($this->id_shop_group === null || !Shop::isFeatureActive()) { $this->id_shop_group = Shop::getContextShopGroupID(); } else { $this->id_shop_group = $this->context->shop->id_shop_group; } $this->trans = $this->getCfTranslations(); $this->file_errors = $this->getFileErrors(); $this->order_steps = $this->getCheckoutSteps(); // zelgra onepagecheckout module $this->checkOnestepModules( 'onepagecheckout', 'zelgra_is_module', 'pts_is_module' ); // pts onepagecheckout module $this->checkOnestepModules( 'onepagecheckoutps', 'pts_is_module', 'zelgra_is_module' ); } public function install() { if (!$this->existsTab()) { if (!$this->addTab()) { return false; } } Configuration::updateValue( 'CUSTOMFIELD_BLOCK_HEADING', array($this->context->language->id => $this->l('Custom Fields')) ); include dirname(__FILE__) . '/sql/install.php'; if (parent::install() && $this->registerHook(array( 'header', 'newOrder', 'adminOrder', 'ModuleRoutes', 'displayPaymentTop', 'displayPDFInvoice', 'displayPDFDeliverySlip', 'displayAfterCarrier', 'orderDetailDisplayed', 'displayBackOfficeHeader', 'displayShoppingCartFooter', 'registerGDPRConsent', 'actionDeleteGDPRCustomer', 'actionExportGDPRData', ))) { return true; } return false; } public function uninstall() { if (!$this->removeTab()) { return false; } include dirname(__FILE__) . '/sql/uninstall.php'; $this->unregisterHook('header'); $this->unregisterHook('newOrder'); $this->unregisterHook('adminOrder'); $this->unregisterHook('displayPaymentTop'); $this->unregisterHook('displayPDFInvoice'); $this->unregisterHook('orderDetailDisplayed'); $this->unregisterHook('displayPDFDeliverySlip'); $this->unregisterHook('displayBackOfficeHeader'); $this->unregisterHook('displayShoppingCartFooter'); $this->unregisterHook('registerGDPRConsent'); $this->unregisterHook('actionDeleteGDPRCustomer'); $this->unregisterHook('actionExportGDPRData'); Configuration::deleteByName('CUSTOMFIELD_BLOCK_HEADING'); parent::uninstall(); return true; } private function addTab() { $tab = new Tab(); $tab->class_name = $this->tab_class; $tab->id_parent = 0; $tab->module = $this->tab_module; $tab->name[(int) Configuration::get('PS_LANG_DEFAULT')] = $this->l('Custom Fields'); $tab->add(); $subtab = new Tab(); $subtab->class_name = 'AdminFields'; $subtab->id_parent = $tab->id; $subtab->module = $this->tab_module; $subtab->name[(int) Configuration::get('PS_LANG_DEFAULT')] = $this->l('Manage Custom Fields'); if (true === Tools::version_compare(_PS_VERSION_, '1.7.0.0', '>=')) { $subtab->icon = 'content_paste'; } $subtab->add(); return true; } private function removeTab() { $id_tab = Tab::getIdFromClassName($this->tab_class); $id_tab1 = Tab::getIdFromClassName('AdminFields'); if ($id_tab && $id_tab1) { $tab1 = new Tab($id_tab); $tab2 = new Tab($id_tab1); if ($tab1->delete() && $tab2->delete()) { return true; } } return false; } public function existsTab() { $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT id_tab AS id FROM `' . _DB_PREFIX_ . 'tab` t WHERE LOWER(t.`class_name`) = \'' . pSQL($this->tab_class) . '\''); if (count($result) == 0) { return false; } return true; } public function getContent() { $this->html = $this->display(__FILE__, 'views/templates/hook/info.tpl'); $output = ''; if (Tools::isSubmit('submitConfiguration')) { $message_trads = array(); foreach ($_POST as $key => $value) { if (preg_match('/CUSTOMFIELD_BLOCK_HEADING_/i', $key)) { $id_lang = preg_split('/CUSTOMFIELD_BLOCK_HEADING_/i', $key); $message_trads[(int) $id_lang[1]] = $value; } } Configuration::updateValue('CUSTOMFIELD_BLOCK_HEADING', $message_trads, true); Configuration::updateValue('CUSTOMFIELD_PDF_INVOICE', Tools::getValue('CUSTOMFIELD_PDF_INVOICE')); Configuration::updateValue('CUSTOMFIELD_DELIVERY_SLIP', Tools::getValue('CUSTOMFIELD_DELIVERY_SLIP')); Configuration::updateValue('CUSTOMFIELD_CUSTOMER_EMAIL', Tools::getValue('CUSTOMFIELD_CUSTOMER_EMAIL')); $output .= $this->displayConfirmation($this->l('Configuration updated')); } return $this->html . $output . $this->renderForm(); } public function renderForm() { $radio = (Tools::version_compare(_PS_VERSION_, '1.6', '>=')) ? 'switch' : 'radio'; $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Configuration'), 'icon' => 'icon-cogs', ), 'input' => array( array( 'type' => 'text', 'lang' => true, 'label' => $this->l('Custom Fields Main Heading:'), 'name' => 'CUSTOMFIELD_BLOCK_HEADING', 'col' => 6, ), array( 'type' => $radio, 'label' => $this->l('Show Fields on PDF Invoice'), 'desc' => $this->l('Display custom fields in PDF invoice Page.'), 'name' => 'CUSTOMFIELD_PDF_INVOICE', 'values' => array( array( 'id' => 'CUSTOMFIELD_PDF_INVOICE_on', 'value' => 1, 'label' => $this->l('Yes'), ), array( 'id' => 'CUSTOMFIELD_PDF_INVOICE_off', 'value' => 0, 'label' => $this->l('No'), ), ), ), array( 'type' => $radio, 'label' => $this->l('Show Fields on PDF Delivery Slip'), 'desc' => $this->l('Display custom fields in PDF Delivery Slip page.'), 'name' => 'CUSTOMFIELD_DELIVERY_SLIP', 'values' => array( array( 'id' => 'CUSTOMFIELD_DELIVERY_SLIP_on', 'value' => 1, 'label' => $this->l('Yes'), ), array( 'id' => 'CUSTOMFIELD_DELIVERY_SLIP_off', 'value' => 0, 'label' => $this->l('No'), ), ), ), array( 'type' => $radio, 'label' => $this->l('Show Fields in Customer Email'), 'desc' => $this->l('Fields will be shown in order confirmation email send to customer.'), 'name' => 'CUSTOMFIELD_CUSTOMER_EMAIL', 'values' => array( array( 'id' => 'CUSTOMFIELD_CUSTOMER_EMAIL_on', 'value' => 1, 'label' => $this->l('Yes'), ), array( 'id' => 'CUSTOMFIELD_CUSTOMER_EMAIL_off', 'value' => 0, 'label' => $this->l('No'), ), ), ), ), 'submit' => array( 'title' => $this->l('Save'), ), ), ); $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->table; $lang = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $this->fields_form = array(); $helper->identifier = $this->identifier; $helper->submit_action = 'submitConfiguration'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id, ); return $helper->generateForm(array($fields_form)); } public function getConfigFieldsValues() { $return = array( 'CUSTOMFIELD_PDF_INVOICE' => Configuration::get('CUSTOMFIELD_PDF_INVOICE', null, $this->id_shop_group, $this->id_shop), 'CUSTOMFIELD_DELIVERY_SLIP' => Configuration::get('CUSTOMFIELD_DELIVERY_SLIP', null, $this->id_shop_group, $this->id_shop), 'CUSTOMFIELD_CUSTOMER_EMAIL' => Configuration::get('CUSTOMFIELD_CUSTOMER_EMAIL', null, $this->id_shop_group, $this->id_shop), ); $languages = Language::getLanguages(false); foreach ($languages as $lang) { $return['CUSTOMFIELD_BLOCK_HEADING'][(int) $lang['id_lang']] = Tools::getValue('CUSTOMFIELD_BLOCK_HEADING_' . (int) $lang['id_lang'], Configuration::get('CUSTOMFIELD_BLOCK_HEADING', (int) $lang['id_lang'])); } return $return; } public function hookDisplayBackOfficeHeader() { $this->context->controller->addCSS($this->_path . 'views/css/admin.css'); } public function hookModuleRoutes() { return array( 'module-' . $this->name . '-ajax' => array( 'controller' => 'ajax', 'rule' => 'checkout-fields', 'keywords' => array(), 'params' => array( 'fc' => 'module', 'module' => $this->name, ), ), ); } public function hookHeader() { $this->ajaxController = Context::getContext()->link->getModuleLink($this->name, 'ajax', array('ajax' => true)); $controller = Dispatcher::getInstance()->getController(); if ($controller == 'orderdetail' || $controller == 'history') { $this->context->controller->addJs($this->_path . 'views/js/accordion_slide.js'); $this->context->controller->addCss($this->_path . 'views/css/accordion_slide.css'); } Media::addJsDef(array('checkout_label' => $this->l('Checkout'))); Media::addJsDef(array('is_required_label' => ' ' . $this->l('is required'))); Media::addJsDef(array('ajax_controller' => $this->ajaxController)); $this->context->controller->addJS(($this->_path) . 'views/js/jquery-watch.js'); $this->context->controller->addCss($this->_path . 'views/css/customfields_common.css'); if (Tools::version_compare(_PS_VERSION_, '1.7.0.0', '>=') == true) { return $this->psNew($controller); } else { return $this->psOld($controller); } } public function hookdisplayPaymentTop() { if (!$this->zelgra_is_module && !$this->pts_is_module) { $id_lang = $this->context->cookie->id_lang; $obj_model = new FieldsModel(); $payment_fields = $obj_model->getCustomFields('payment', $id_lang); $cart_products = array(); if (isset($this->context->cart)) { $cart_products = $this->context->cart->getProducts(false, false, null, false); $payment_fields = $this->filterFieldsByProducts($payment_fields, $cart_products); } if ($payment_fields == false) { $payment_fields = []; } $payment_fields_values = array(); foreach ($payment_fields as $sf) { $payment_fields_values[$sf['id_custom_field']] = $obj_model->getCustomFieldsValues($sf['id_custom_field']); } $model = new FieldsModel(); if (isset($payment_fields) && !empty($payment_fields)) { foreach ($payment_fields as &$field) { if (isset($field['id_heading']) && (int)$field['id_heading'] > 0) { $field['sub_heading'] = $model->getSubHeading($field['id_heading'], $id_lang); } else { $field['sub_heading'] = ''; } } } $this->context->smarty->assign('model', $model); $this->context->smarty->assign('summary_fields_values', $payment_fields_values); $this->context->smarty->assign('summary_fields', $payment_fields); $this->context->smarty->assign('type', 'payment'); $this->context->smarty->assign('CUSTOMFIELD_BLOCK_HEADING', Configuration::get('CUSTOMFIELD_BLOCK_HEADING', $this->context->language->id)); $this->context->smarty->assign('version', _PS_VERSION_); $this->context->smarty->assign('action_controller', $this->ajaxController); return $this->display(__FILE__, 'summary.tpl'); } } public function hookNewOrder($data) { $where = array('id_order' => $data['order']->id); if (Tools::version_compare(_PS_VERSION_, '1.7.0.0', '>=') == true) { Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'custom_field_userdata` SET `id_order` = ' . (int) $data['order']->id . ' WHERE `id_cart` = ' . (int) $data['order']->id_cart); } else { Db::getInstance(_PS_USE_SQL_SLAVE_)->autoexecute(_DB_PREFIX_ . 'custom_field_userdata', $where, 'UPDATE', 'id_cart =' . (int) $data['order']->id_cart); } } public function hookdisplayShoppingCartFooter() { $id_lang = $this->context->cookie->id_lang; $obj_model = new FieldsModel(); $summary_fields = $obj_model->getCustomFields('summary', $id_lang); $summary_fields_values = array(); $cart_products = array(); if (isset($this->context->cart)) { $cart_products = $this->context->cart->getProducts(false, false, null, false); $summary_fields = $this->filterFieldsByProducts($summary_fields, $cart_products); } if (isset($summary_fields) && $summary_fields) { foreach ($summary_fields as $sf) { $summary_fields_values[$sf['id_custom_field']] = $obj_model->getCustomFieldsValues($sf['id_custom_field']); } $model = new FieldsModel(); if (isset($summary_fields) && !empty($summary_fields)) { foreach ($summary_fields as &$field) { if (isset($field['id_heading']) && (int)$field['id_heading'] > 0) { $field['sub_heading'] = $model->getSubHeading($field['id_heading'], $id_lang); } else { $field['sub_heading'] = ''; } } } $this->context->smarty->assign('model', $model); $this->context->smarty->assign('version', _PS_VERSION_); $this->context->smarty->assign('summary_fields_values', $summary_fields_values); $this->context->smarty->assign('summary_fields', $summary_fields); $this->context->smarty->assign('type', 'summary'); $this->context->smarty->assign('CUSTOMFIELD_BLOCK_HEADING', Configuration::get('CUSTOMFIELD_BLOCK_HEADING', $this->context->language->id)); $this->context->smarty->assign('action_controller', $this->ajaxController); if (isset($this->context->cart) && $this->context->cart->getProducts()) { return $this->display(__FILE__, 'summary.tpl'); } } } public function hookOrderDetailDisplayed($params) { $id_lang = $this->context->cookie->id_lang; $id_shop = $this->context->shop->id; $id_order = (isset($params) && isset($params['order']) && $params['order']->id) ? $params['order']->id : 0; $id_cart = (isset($params) && isset($params['order']) && $params['order']->id_cart) ? $params['order']->id_cart : 0; $model = new FieldsModel(); $cart = null; $summary_fields = FieldsModel::getCustomFields('summary', $id_lang, $id_shop, $id_cart, 't.show_customer = 1'); $delivery_fields = FieldsModel::getCustomFields('delivery', $id_lang, $id_shop, $id_cart, 't.show_customer = 1'); $billing_fields = FieldsModel::getCustomFields('billing', $id_lang, $id_shop, $id_cart, 't.show_customer = 1'); $shipping_fields = FieldsModel::getCustomFields('shipping', $id_lang, $id_shop, $id_cart, 't.show_customer = 1'); $payment_fields = FieldsModel::getCustomFields('payment', $id_lang, $id_shop, $id_cart, 't.show_customer = 1'); if ($id_cart) { $cart = new Cart($id_cart); $cart_products = array(); if (isset($cart)) { $cart_products = $cart->getProducts(false, false, null, false); $summary_fields = $this->filterFieldsByProducts($summary_fields, $cart_products); $delivery_fields = $this->filterFieldsByProducts($delivery_fields, $cart_products); $billing_fields = $this->filterFieldsByProducts($billing_fields, $cart_products); $shipping_fields = $this->filterFieldsByProducts($shipping_fields, $cart_products); $payment_fields = $this->filterFieldsByProducts($payment_fields, $cart_products); } } $checkout_fields = array( 'summary' => $summary_fields, 'delivery' => $delivery_fields, 'billing' => $billing_fields, 'shipping' => $shipping_fields, 'payment' => $payment_fields, ); $customfields_heading = Configuration::get('CUSTOMFIELD_BLOCK_HEADING', $this->context->language->id); $this->context->smarty->assign('model', $model); $this->context->smarty->assign('id_module', $this->id); $this->context->smarty->assign('id_order', $id_order); $this->context->smarty->assign('id_cart', $id_cart); $this->context->smarty->assign('version', _PS_VERSION_); $this->context->smarty->assign('checkout_labels', $this->order_steps); $this->context->smarty->assign('checkout_fields', $checkout_fields); $this->context->smarty->assign('customfields_heading', $customfields_heading); $this->context->smarty->assign('is_editable', FieldsModel::countEditableFields()); $this->context->smarty->assign('nbrNonEditableValues', FieldsModel::countEditableFieldValues($id_cart)); $this->context->smarty->assign('nbrMissingFields', FieldsModel::countNonEditableMissigFields($id_cart)); $this->context->smarty->assign('action_controller', Context::getContext()->link->getModuleLink($this->name, 'ajax', array('ajax' => true))); return $this->display(__FILE__, 'order_fields.tpl'); } public function hookAdminOrder($params) { $id_order = $params['id_order']; if ($id_order && Validate::isLoadedObject($order = new Order($id_order))) { $model = new FieldsModel(); $fields = $model->getOrderFields('val.id_order = ' . (int) $id_order . ' and a.show_admin = 1'); if (isset($fields) && $fields) { $customfields_heading = Configuration::get('CUSTOMFIELD_BLOCK_HEADING', $this->context->language->id); $grouped_fields = array(); foreach ($fields as $field) { $grouped_fields[$field['field_placement']][] = $field; } $this->smarty->assign(array( 'version' => _PS_VERSION_, 'checkout_steps' => $this->order_steps, 'grouped_fields' => $grouped_fields, 'customfields_heading' => $customfields_heading, 'obj_model' => $model, 'downloadLink' => $this->context->link->getAdminLink('AdminFields'), ) ); return $this->display(dirname(__FILE__), 'views/templates/admin/admin_fields.tpl'); } } } public function hookDisplayAfterCarrier() { if (Tools::version_compare(_PS_VERSION_, '1.7.0.0', '>=')) { $id_lang = $this->context->cookie->id_lang; $obj_model = new FieldsModel(); $shipping_fields = FieldsModel::getCustomFields('shipping', $id_lang); $cart_products = array(); if (isset($this->context->cart)) { $cart_products = $this->context->cart->getProducts(false, false, null, false); $shipping_fields = $this->filterFieldsByProducts($shipping_fields, $cart_products); } if (isset($shipping_fields) && $shipping_fields) { $shipping_fields_values = array(); foreach ($shipping_fields as $sf) { $shipping_fields_values[$sf['id_custom_field']] = $obj_model->getCustomFieldsValues($sf['id_custom_field']); } $model = new FieldsModel(); if (isset($shipping_fields) && !empty($shipping_fields)) { foreach ($shipping_fields as &$field) { if (isset($field['id_heading']) && (int)$field['id_heading'] > 0) { $field['sub_heading'] = $model->getSubHeading($field['id_heading'], $id_lang); } else { $field['sub_heading'] = ''; } } } $this->context->smarty->assign('model', $model); $this->context->smarty->assign('version', _PS_VERSION_); $this->context->smarty->assign('summary_fields_values', $shipping_fields_values); $this->context->smarty->assign('summary_fields', $shipping_fields); $this->context->smarty->assign('type', 'shipping'); $this->context->smarty->assign('CUSTOMFIELD_BLOCK_HEADING', Configuration::get('CUSTOMFIELD_BLOCK_HEADING', $this->context->language->id)); $this->context->smarty->assign('action_controller', $this->ajaxController); return $this->display(__FILE__, 'summary.tpl'); } } } public function hookDisplayPDFDeliverySlip($params) { $id_order = $params['object']->id_order; if (Configuration::get('CUSTOMFIELD_DELIVERY_SLIP', null, $this->id_shop_group, $this->id_shop) == 1) { return $this->getPDFFields($id_order); } } public function hookDisplayPDFInvoice($params) { $id_order = $params['object']->id_order; if (Configuration::get('CUSTOMFIELD_PDF_INVOICE', null, $this->id_shop_group, $this->id_shop) == 1) { return $this->getPDFFields($id_order); } } public function getEmailFields($id_order, $where = null) { if ($id_order && Validate::isLoadedObject($order = new Order($id_order))) { $model = new FieldsModel(); if (!$where) { $where = ' and a.show_admin = 1'; } $fields = $model->getOrderFields('val.id_order = ' . (int) $id_order . $where); if (isset($fields) && $fields) { $customfields_heading = Configuration::get('CUSTOMFIELD_BLOCK_HEADING', $this->context->language->id); $grouped_fields = array(); foreach ($fields as $field) { $grouped_fields[$field['field_placement']][] = $field; } return $grouped_fields; } } } public function getPDFFields($id_order, $where = null) { if ($id_order && Validate::isLoadedObject($order = new Order($id_order))) { $model = new FieldsModel(); if (!$where) { $where = ' and a.show_admin = 1'; } $fields = $model->getOrderFields('val.id_order = ' . (int) $id_order . $where); if (isset($fields) && $fields) { $customfields_heading = Configuration::get('CUSTOMFIELD_BLOCK_HEADING', $this->context->language->id); $grouped_fields = array(); foreach ($fields as $field) { $grouped_fields[$field['field_placement']][] = $field; } $this->smarty->assign(array( 'version' => _PS_VERSION_, 'checkout_steps' => $this->order_steps, 'grouped_fields' => $grouped_fields, 'customfields_heading' => $customfields_heading, 'obj_model' => $model, ) ); return $this->display(dirname(__FILE__), 'views/templates/admin/pdf/pdf_customfields.tpl'); } } } public function psOld($controller) { // Get controller if (!in_array($controller, array('orderopc', 'order', 'orderdetail', 'history'))) { return false; } $id_lang = $this->context->cookie->id_lang; $this->context->controller->addCSS(__PS_BASE_URI__ . 'js/jquery/ui/themes/base/jquery.ui.theme.css', 'all'); $this->context->controller->addCSS(__PS_BASE_URI__ . 'js/jquery/ui/themes/base/jquery.ui.datepicker.css', 'all'); $this->context->controller->addCSS(($this->_path) . 'views/css/customfields.css', 'all'); $this->context->controller->addJS(($this->_path) . 'views/js/customfields.js'); $this->context->controller->addJqueryUI('ui.datepicker'); $this->context->controller->addJS(($this->_path) . 'views/js/validate_custom_fields.js'); $obj_model = new FieldsModel(); if (Tools::getValue('step') == '1') { $summary_fields = $obj_model->getCustomFields('summary', $id_lang); $cart_products = array(); if (isset($this->context->cart)) { $cart_products = $this->context->cart->getProducts(false, false, null, false); $summary_fields = $this->filterFieldsByProducts($summary_fields, $cart_products); } $fields = array(); foreach ($summary_fields as $field) { $fields[$field['id_custom_field']] = $field['field_value']; } if (count(FieldsModel::fieldValidate('summary', $fields)) > 0) { Tools::redirect('order.php'); } } $script = ''; return $script; } public function psNew($controller) { // Get controller if (!in_array($controller, array('cart', 'order', 'orderdetail'))) { return false; } $this->context->controller->registerStylesheet( 'theme-css', 'js/jquery/ui/themes/base/jquery.ui.theme.css', array('media' => 'all', 'priority' => 50) ); $this->context->controller->registerStylesheet( 'datepicker-css', 'js/jquery/ui/themes/base/jquery.ui.datepicker.css', array('media' => 'all', 'priority' => 50) ); $this->context->controller->registerStylesheet( 'customfields_17css', 'modules/' . $this->name . '/views/css/customfields_17.css', array('priority' => 900, 'media' => 'all') ); $this->context->controller->addJqueryUI('ui.datepicker'); if ($this->pts_is_module) { $this->context->controller->registerJavascript( 'customfieldsjs', 'modules/' . $this->name . '/views/js/customfields.js', array('position' => 'bottom', 'priority' => 1000) ); } else { $this->context->controller->registerJavascript( 'customfields_17js', 'modules/' . $this->name . '/views/js/customfields_17.js', array('position' => 'bottom', 'priority' => 1000) ); } $this->context->controller->registerJavascript( 'validate_custom_fields_17js', 'modules/' . $this->name . '/views/js/validate_custom_fields_17.js', array('position' => 'bottom', 'priority' => 1001) ); $force_ssl = (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE')); $base_dir = ($force_ssl == 1) ? _PS_BASE_URL_SSL_ . __PS_BASE_URI__ : _PS_BASE_URL_ . __PS_BASE_URI__; $script = ''; $script .= ''; return $script; } protected function summaryJavascript() { $id_lang = $this->context->cookie->id_lang; $obj_model = new FieldsModel(); $summary_fields = $obj_model->getCustomFields('summary', $id_lang); $cart_products = array(); if (isset($this->context->cart)) { $cart_products = $this->context->cart->getProducts(false, false, null, false); $summary_fields = $this->filterFieldsByProducts($summary_fields, $cart_products); } if (count($summary_fields)) { return 'orderStep(\'summary\');'; } return ''; } public function addressJavascript() { $id_lang = $this->context->cookie->id_lang; $obj_model = new FieldsModel(); $billing_fields = $obj_model->getCustomFields('billing', $id_lang); $delivery_fields = $obj_model->getCustomFields('delivery', $id_lang); $cart_products = array(); if (isset($this->context->cart)) { $cart_products = $this->context->cart->getProducts(false, false, null, false); $billing_fields = $this->filterFieldsByProducts($billing_fields, $cart_products); $delivery_fields = $this->filterFieldsByProducts($delivery_fields, $cart_products); } $js = ''; $this->context->smarty->assign('version', _PS_VERSION_); $this->context->smarty->assign('action_controller', $this->ajaxController); if (count($billing_fields)) { $js .= 'orderStep(\'billing\');'; } if (count($delivery_fields)) { $js .= 'orderStep(\'delivery\');'; } $billing_html = ''; $shipping_html = ''; if (isset($billing_fields) && $billing_fields) { // billing fields $summary_fields_values = array(); foreach ($billing_fields as $sf) { $summary_fields_values[$sf['id_custom_field']] = $obj_model->getCustomFieldsValues($sf['id_custom_field']); } $model = new FieldsModel(); if (isset($billing_fields) && !empty($billing_fields)) { foreach ($billing_fields as &$field) { if (isset($field['id_heading']) && (int)$field['id_heading'] > 0) { $field['sub_heading'] = $model->getSubHeading($field['id_heading'], $id_lang); } else { $field['sub_heading'] = ''; } } } $this->context->smarty->assign('model', $model); $this->context->smarty->assign('summary_fields_values', $summary_fields_values); $this->context->smarty->assign('summary_fields', $billing_fields); $this->context->smarty->assign('type', 'billing'); $this->context->smarty->assign('CUSTOMFIELD_BLOCK_HEADING', Configuration::get('CUSTOMFIELD_BLOCK_HEADING', $this->context->language->id)); $billing_html = '