✏️ 正在编辑: easycart.php
路径:
/home/bpioifn/www/pigmentse/modules/easycart/easycart.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php /** * Please do not edit or add any code in this file without the permission of PIBBLU * * @author Saravana Technology Solutions * @copyright Saravana Technology Solutions * @license http://www.pibblu.in * Prestashop version 1.7+ * easycart 1.0.0 * Dec 2017 */ if (!defined('_PS_VERSION_')) { exit; } require_once(_PS_MODULE_DIR_.'easycart/classes/ecpricetext.php'); class EasyCart extends Module { public function __construct() { $this->name = 'easycart'; $this->tab = 'front_office_features'; $this->version = '17.0.26'; $this->author = 'Saravana Technology Solutions'; $this->module_key = '9977ea079a330617273cfa90c192a37e'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Quick Add to Cart. Add Multiple Quantity Instantly'); $this->description = $this->l('Quickly add multiple products to Cart from Home page and Category page. Plus, Minus icons and Type watch text box to instantly update Product quantity. Highlight products in Cart.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); $this->_tabsArray = array(); $this->tabsArray_hidden = array('AdminEcPriceText' => 'Easycart Price Text',); } public function getContent() { $output = ''; if (Tools::isSubmit('submitEasyCart')) { $mc_price_text = (int)Tools::getValue('MC_PRICE_TEXT', 0); Configuration::updateValue('MC_PRICE_TEXT', $mc_price_text); $MC_COMB_STOCK_IMG = (int)Tools::getValue('MC_COMB_STOCK_IMG', 0); Configuration::updateValue('MC_COMB_STOCK_IMG', $MC_COMB_STOCK_IMG); $MC_DISPLAY_COMB_OOS = (int)Tools::getValue('MC_DISPLAY_COMB_OOS', 1); Configuration::updateValue('MC_DISPLAY_COMB_OOS', $MC_DISPLAY_COMB_OOS); $mc_highlight_option = (string)Tools::getValue('MC_PROD_CART_HIGHLIGHT', 'Product_Box_Color'); Configuration::updateValue('MC_PROD_CART_HIGHLIGHT', $mc_highlight_option); $mc_prod_box_color = (string)Tools::getValue('MC_SELECTED_PROD_BOX_COLOR', '#e4e4e4'); Configuration::updateValue('MC_SELECTED_PROD_BOX_COLOR', $mc_prod_box_color); $MC_TICK_COLOR = Tools::getValue('MC_TICK_COLOR', 'pink'); Configuration::updateValue('MC_TICK_COLOR', $MC_TICK_COLOR); $MC_HIDE_COMB_STOCK = Tools::getValue('MC_HIDE_COMB_STOCK', 0); Configuration::updateValue('MC_HIDE_COMB_STOCK', $MC_HIDE_COMB_STOCK); $MC_DISPLAY_LAST_STOCK = Tools::getValue('MC_DISPLAY_LAST_STOCK', 0); Configuration::updateValue('MC_DISPLAY_LAST_STOCK', $MC_DISPLAY_LAST_STOCK); $MC_HIDE_COMB_MIN = Tools::getValue('MC_HIDE_COMB_MIN', 0); Configuration::updateValue('MC_HIDE_COMB_MIN', $MC_HIDE_COMB_MIN); $MC_TICK_POSITION = Tools::getValue('MC_TICK_POSITION', 50); Configuration::updateValue('MC_TICK_POSITION', $MC_TICK_POSITION); $MC_TICK_WIDTH = Tools::getValue('MC_TICK_WIDTH', 48); Configuration::updateValue('MC_TICK_WIDTH', $MC_TICK_WIDTH); $MC_TICK_HEIGHT = Tools::getValue('MC_TICK_HEIGHT', 48); Configuration::updateValue('MC_TICK_HEIGHT', $MC_TICK_HEIGHT); $MC_PD_WIDTH = Tools::getValue('MC_PD_WIDTH', 100); Configuration::updateValue('MC_PD_WIDTH', $MC_PD_WIDTH); $MC_PD_IMG_WIDTH = Tools::getValue('MC_PD_IMG_WIDTH', 100); Configuration::updateValue('MC_PD_IMG_WIDTH', $MC_PD_IMG_WIDTH); $MC_PD_IMG_DISPLAY = Tools::getValue('MC_PD_IMG_DISPLAY', 1); Configuration::updateValue('MC_PD_IMG_DISPLAY', $MC_PD_IMG_DISPLAY); $MC_PD_COLUMN_GAP = Tools::getValue('MC_PD_COLUMN_GAP', 50); Configuration::updateValue('MC_PD_COLUMN_GAP', $MC_PD_COLUMN_GAP); $MC_DD_WIDTH = Tools::getValue('MC_DD_WIDTH', 110); Configuration::updateValue('MC_DD_WIDTH', $MC_DD_WIDTH); $MC_DD_1VARIANT = Tools::getValue('MC_DD_1VARIANT', 1); Configuration::updateValue('MC_DD_1VARIANT', $MC_DD_1VARIANT); $MC_DD_COLUMN_GAP = Tools::getValue('MC_DD_COLUMN_GAP', 50); Configuration::updateValue('MC_DD_COLUMN_GAP', $MC_DD_COLUMN_GAP); $MC_ADDED_TO_CART_BGCOLOR = (string)Tools::getValue('MC_ADDED_TO_CART_BGCOLOR', '#55c65e'); Configuration::updateValue('MC_ADDED_TO_CART_BGCOLOR', $MC_ADDED_TO_CART_BGCOLOR); $MC_PLUSMINUS_BGCOLOR = (string)Tools::getValue('MC_PLUSMINUS_BGCOLOR', '#55c65e'); Configuration::updateValue('MC_PLUSMINUS_BGCOLOR', $MC_PLUSMINUS_BGCOLOR); $MC_OOS_BOX_COLOR = (string)Tools::getValue('MC_OOS_BOX_COLOR', '#55c65e'); Configuration::updateValue('MC_OOS_BOX_COLOR', $MC_OOS_BOX_COLOR); $MC_OOS_LABEL_COLOR = (string)Tools::getValue('MC_OOS_LABEL_COLOR', '#ffffff'); Configuration::updateValue('MC_OOS_LABEL_COLOR', $MC_OOS_LABEL_COLOR); $MC_CART_ICON_BGCOLOR = (string)Tools::getValue('MC_CART_ICON_BGCOLOR', '#ffffff'); Configuration::updateValue('MC_CART_ICON_BGCOLOR', $MC_CART_ICON_BGCOLOR); $MC_ADDED_TO_CART_TXTCOLOR = (string)Tools::getValue('MC_ADDED_TO_CART_TXTCOLOR', '#ffffff'); Configuration::updateValue('MC_ADDED_TO_CART_TXTCOLOR', $MC_ADDED_TO_CART_TXTCOLOR); $MC_ADD_VARIANT_TXTCOLOR = (string)Tools::getValue('MC_ADD_VARIANT_TXTCOLOR', '#ffffff'); Configuration::updateValue('MC_ADD_VARIANT_TXTCOLOR', $MC_ADD_VARIANT_TXTCOLOR); $mc_min_qty_text_display = (int)Tools::getValue('MC_MIN_QTY_TEXT_DISPLAY', 1); Configuration::updateValue('MC_MIN_QTY_TEXT_DISPLAY', (int)$mc_min_qty_text_display); $mc_easycart_direct = (int)Tools::getValue('MC_DISPLAY_COMB_DIRECTLY', 1); Configuration::updateValue('MC_DISPLAY_COMB_DIRECTLY', (int)$mc_easycart_direct); $MC_APPLY_FOR_SINGLE = (int)Tools::getValue('MC_APPLY_FOR_SINGLE', 1); Configuration::updateValue('MC_APPLY_FOR_SINGLE', (int)$MC_APPLY_FOR_SINGLE); $MC_APPLY_FOR_COMB = (int)Tools::getValue('MC_APPLY_FOR_COMB', 1); Configuration::updateValue('MC_APPLY_FOR_COMB', (int)$MC_APPLY_FOR_COMB); $MC_PD_SIMPLE_ADD_TO_CART = (int)Tools::getValue('MC_PD_SIMPLE_ADD_TO_CART', 0); Configuration::updateValue('MC_PD_SIMPLE_ADD_TO_CART', (int)$MC_PD_SIMPLE_ADD_TO_CART); $MC_PD_HIDE_DEFAULT_CART = (int)Tools::getValue('MC_PD_HIDE_DEFAULT_CART', 0); Configuration::updateValue('MC_PD_HIDE_DEFAULT_CART', (int)$MC_PD_HIDE_DEFAULT_CART); $mc_variant_text_display = (int)Tools::getValue('MC_VARIANT_CART_TEXT_DISPLAY', 1); Configuration::updateValue('MC_VARIANT_CART_TEXT_DISPLAY', (int)$mc_variant_text_display); $mc_comb_hook = (string)Tools::getValue('MC_COMB_DISPLAY_HOOK', 'donotdisplay'); $mc_comb_existing_hook = (string)Configuration::get('MC_COMB_DISPLAY_HOOK'); if ($mc_comb_existing_hook !== $mc_comb_hook) { if ($mc_comb_hook === 'donotdisplay' || empty($mc_comb_existing_hook)) { $this->unregisterHook('displayReassurance'); $this->unregisterHook('displayProductAdditionalInfo'); $this->unregisterHook('displayAfterProductThumbs'); $this->unregisterHook('displayAdminProductsExtra'); $this->unregisterHook('displayECPD'); } else { $this->unregisterHook('displayReassurance'); $this->unregisterHook('displayProductAdditionalInfo'); $this->unregisterHook('displayAfterProductThumbs'); $this->unregisterHook('displayAdminProductsExtra'); $this->unregisterHook('displayECPD'); $this->registerHook($mc_comb_hook); } Configuration::updateValue('MC_COMB_DISPLAY_HOOK', $mc_comb_hook); } $this->updateProductCombinationsHook(); $ajax = (int)Tools::getValue('PS_EASY_CART_AJAX'); if ($ajax != 0 && $ajax != 1) { $output .= $this->displayError($this->l('Ajax: Invalid choice.')); } else { Configuration::updateValue('PS_EASY_CART_AJAX', $ajax); } Configuration::updateValue('MC_MANUAL_BULK', (int)Tools::getValue('MC_MANUAL_BULK')); Configuration::updateValue('PS_EASY_CART_SHOW_CROSSSELLING', (int)Tools::getValue('PS_EASY_CART_SHOW_CROSSSELLING')); $this->context->controller->confirmations[] = 'Settings Updated'; } return $output.$this->renderForm(); } public function hookDisplayAdminProductsExtra($params) { $id_product = (int)Tools::getValue('id_product'); if ($id_product) { $this->product = new Product($id_product, false, $this->context->language->id, $this->context->shop->id); $this->assignImages(); $res = $this->assignAttributesGroups(); return $res; } } public function hookDisplayProductListCustom($params) { return $this->getProductCombinations($params['product']); } public function updateProductCombinationsHook() { $eligibleHooks = $this->getCombinationsHooks(); $configName = 'EASYCART_PROD_COMB_HOOK'; $this->changeHookAndRegister($configName, $eligibleHooks); } public function getCombinationsHooks() { return array( array( 'id' => 'displayProductListReviews', 'name' => $this->l('Display Product List Reviews')), array( 'id' => 'displayReviewProductList', 'name' => $this->l('Display Product List Reviews PSv1752')), array( 'id' => 'displayProductPriceBlock', 'name' => $this->l('Display Next to Product Price')), array( 'id' => 'displayProductListCustom', 'name' => $this->l('Display in Custom Location')), array( 'id' => 'donotdisplay', 'name' => $this->l('Do Not Display')), ); } public function changeHookAndRegister($configName, $eligibleHooks) { $newHook = (string)Tools::getValue($configName, 'donotdisplay'); $existingHook = (string)Configuration::get($configName); if ($existingHook !== $newHook) { if ($newHook === 'donotdisplay' || empty($existingHook)) { foreach ($eligibleHooks as $hooks) { if ($hooks['id'] != 'donotdisplay') { $this->unregisterHook($hooks['id']); } } } else { if (!empty($existingHook) && $existingHook != 'donotdisplay') { $this->unregisterHook($existingHook); } $this->registerHook($newHook); } Configuration::updateValue($configName, $newHook); } } public function install() { if (parent::install() == false || $this->registerHook('header') == false || Configuration::updateValue('PS_EASY_CART_AJAX', 1) == false || Configuration::updateValue('MC_PD_SIMPLE_ADD_TO_CART', 1) == false || Configuration::updateValue('MC_PD_HIDE_DEFAULT_CART', 1) == false || Configuration::updateValue('MC_MANUAL_BULK', 1) == false || Configuration::updateValue('MC_SELECTED_PROD_BOX_COLOR', '#e4e4e4') == false || Configuration::updateValue('MC_ADDED_TO_CART_BGCOLOR', '#55c65e') == false || Configuration::updateValue('MC_PLUSMINUS_BGCOLOR', '#55c65e') == false || Configuration::updateValue('MC_PROD_CART_HIGHLIGHT', 'Product_Box_Color') || Configuration::updateValue('MC_CART_ICON_BGCOLOR', '#55c65e') == false || Configuration::updateValue('MC_ADDED_TO_CART_TXTCOLOR', '#ffffff') == false || Configuration::updateValue('MC_ADD_VARIANT_TXTCOLOR', '#ffffff') == false || Configuration::updateValue('MC_MIN_QTY_TEXT_DISPLAY', 1) == false || Configuration::updateValue('MC_DISPLAY_COMB_OOS', 1) == false || Configuration::updateValue('MC_DISPLAY_COMB_DIRECTLY', 0) == false || Configuration::updateValue('MC_APPLY_FOR_SINGLE', 1) == false || Configuration::updateValue('MC_APPLY_FOR_COMB', 1) == false || Configuration::updateValue('MC_TICK_COLOR', 'pink') == false || Configuration::updateValue('MC_PD_WIDTH', 100) == false || Configuration::updateValue('MC_PD_IMG_WIDTH', 100) == false || Configuration::updateValue('MC_PD_IMG_DISPLAY', 1) == false || Configuration::updateValue('MC_PD_COLUMN_GAP', 50) == false || Configuration::updateValue('MC_HIDE_COMB_STOCK', 0) == false || Configuration::updateValue('MC_DISPLAY_LAST_STOCK', 0) == false || Configuration::updateValue('MC_HIDE_COMB_MIN', 0) == false || Configuration::updateValue('MC_TICK_POSITION', 50) == false || Configuration::updateValue('MC_DD_WIDTH', 110) == false || Configuration::updateValue('MC_DD_1VARIANT', 1) == false || Configuration::updateValue('MC_DD_COLUMN_GAP', 50) == false || Configuration::updateValue('MC_VARIANT_CART_TEXT_DISPLAY', 1) == false || Configuration::updateValue('MC_COMB_STOCK_IMG', 0) == false || Configuration::updateValue('EASYCART_PROD_COMB_HOOK', 'displayReviewProductList') == false || Configuration::updateValue('MC_COMB_DISPLAY_HOOK', 'displayAfterProductThumbs') == false || $this->registerHook('displayReviewProductList') == false || $this->registerHook('displayAfterProductThumbs') == false ) { return false; } include(dirname(__FILE__).'/sql/install.php'); $this->_installTabs(); return true; } public function _installTabs() { $idTab = (int)Tab::getIdFromClassName('AdminParentModulesSf'); foreach ($this->_tabsArray as $tabKey => $name) { $childTab = new Tab(); foreach (Language::getLanguages() as $language) { $childTab->name[$language['id_lang']] = $name; } $childTab->class_name = $tabKey; $childTab->module = $this->name; $childTab->id_parent = $idTab; if (!$childTab->save()) { return false; } } foreach ($this->tabsArray_hidden as $tabKey => $name) { $childTab = new Tab(); foreach (Language::getLanguages() as $language) { $childTab->name[$language['id_lang']] = $name; } $childTab->class_name = $tabKey; $childTab->module = $this->name; $childTab->id_parent = -1; if (!$childTab->save()) { return false; } } return true; } public function uninstall() { $this->unsetConfigurations(); include(dirname(__FILE__).'/sql/uninstall.php'); $this->_uninstallTabs(); return parent::uninstall(); } public function unsetConfigurations() { Configuration::deleteByName('PS_EASY_CART_AJAX'); Configuration::deleteByName('MC_PD_SIMPLE_ADD_TO_CART'); Configuration::deleteByName('MC_PD_HIDE_DEFAULT_CART'); Configuration::deleteByName('MC_MANUAL_BULK'); Configuration::deleteByName('MC_PRICE_TEXT'); Configuration::deleteByName('MC_SELECTED_PROD_BOX_COLOR'); Configuration::deleteByName('MC_ADDED_TO_CART_BGCOLOR'); Configuration::deleteByName('MC_PLUSMINUS_BGCOLOR'); Configuration::deleteByName('MC_OOS_LABEL_COLOR'); Configuration::deleteByName('MC_OOS_BOX_COLOR'); Configuration::deleteByName('MC_CART_ICON_BGCOLOR'); Configuration::deleteByName('MC_ADDED_TO_CART_TXTCOLOR'); Configuration::deleteByName('MC_ADD_VARIANT_TXTCOLOR'); Configuration::deleteByName('MC_MIN_QTY_TEXT_DISPLAY'); Configuration::deleteByName('MC_DISPLAY_COMB_DIRECTLY'); Configuration::deleteByName('MC_APPLY_FOR_COMB'); Configuration::deleteByName('MC_APPLY_FOR_SINGLE'); Configuration::deleteByName('MC_VARIANT_CART_TEXT_DISPLAY'); Configuration::deleteByName('MC_COMB_STOCK_IMG'); Configuration::deleteByName('EASYCART_PROD_COMB_HOOK'); Configuration::deleteByName('MC_COMB_DISPLAY_HOOK'); } public function _uninstallTabs() { foreach ($this->_tabsArray as $tabKey => $name) { $idTab = Tab::getIdFromClassName($tabKey); if ($idTab != 0) { $tab = new Tab($idTab); $tab->delete(); } } foreach ($this->tabsArray_hidden as $tabKey => $name) { $idTab = Tab::getIdFromClassName($tabKey); if ($idTab != 0) { $tab = new Tab($idTab); $tab->delete(); } } return true; } public function getQtyText($id_product) { $id_lang = $this->context->language->id; $priceText = Ecpricetext::getPriceText($id_product, $id_lang); if (empty($priceText)) { return ''; } return $priceText; } public function hookDisplayProductPriceBlock($params) { $mc_price_text = (int)Configuration::get('MC_PRICE_TEXT'); if ($mc_price_text) { $id = Tools::getValue('id_product'); if (empty($id)) { $id = $params['product']['id_product']; } $text = $this->getQtyText((int)$id); return $text; } } public function hookDisplayProductListReviews($params) { //$id = $params['product']['id_product']; //$text = $this->getQtyText($id); //return $this->getProductCombinations($params['product']).$text; return $this->getProductCombinations($params['product']); } public function hookDisplayReviewProductList($params) { //$id = $params['product']['id_product']; //$text = $this->getQtyText($id); //return $this->getProductCombinations($params['product']).$text; return $this->hookDisplayProductListReviews($params); } public function hookHeader() { if (Configuration::get('PS_CATALOG_MODE')) { return; } Media::addJsDef(array('baseDir' => __PS_BASE_URI__)); Media::addJsDef(array('baseUri' => __PS_BASE_URI__)); $this->context->controller->addJqueryPlugin(array('scrollTo', 'serialScroll', 'bxslider')); //if (!Configuration::get('PS_QUICK_VIEW')) { $this->context->controller->addjqueryPlugin('fancybox'); //} /* Multicart - Change - Start */ if ($this->isEligiblePage()) { $this->context->controller->addCSS(($this->_path).'views/css/multicart.css', 'all'); $this->context->controller->addJqueryPlugin(array('typewatch')); if (Configuration::get('PS_EASY_CART_AJAX') == 1) { $this->context->controller->addJS(($this->_path).'views/js/combination_hook_js.js'); } else { $this->context->controller->addJS(($this->_path).'views/js/combination_hook_manual_js.js'); } if ($this->context->controller->php_self === 'product' && Configuration::get('MC_PD_HIDE_DEFAULT_CART')) { $this->context->controller->addJS(($this->_path).'views/js/pd_js.js'); } $this->smarty->assign(array( 'PS_EASY_CART_AJAX' => Configuration::get('PS_EASY_CART_AJAX'), 'MC_COMB_STOCK_IMG' => Configuration::get('MC_COMB_STOCK_IMG'), 'MC_MIN_QTY_TEXT_DISPLAY' => Configuration::get('MC_MIN_QTY_TEXT_DISPLAY'), 'MC_PROD_CART_HIGHLIGHT' => Configuration::get('MC_PROD_CART_HIGHLIGHT'), 'MC_VARIANT_CART_TEXT_DISPLAY' => Configuration::get('MC_VARIANT_CART_TEXT_DISPLAY'), 'MC_ADDED_TO_CART_BGCOLOR' => Configuration::get('MC_ADDED_TO_CART_BGCOLOR'), 'MC_PLUSMINUS_BGCOLOR' => Configuration::get('MC_PLUSMINUS_BGCOLOR'), 'MC_CART_ICON_BGCOLOR' => Configuration::get('MC_CART_ICON_BGCOLOR'), 'MC_ADDED_TO_CART_TXTCOLOR' => Configuration::get('MC_ADDED_TO_CART_TXTCOLOR'), 'MC_ADD_VARIANT_TXTCOLOR' => Configuration::get('MC_ADD_VARIANT_TXTCOLOR'), 'MC_SELECTED_PROD_BOX_COLOR' => Configuration::get('MC_SELECTED_PROD_BOX_COLOR'))); if (Configuration::get('PS_EASY_CART_AJAX') == 1) { return $this->display(__FILE__, 'multicart_ajax.tpl'); } else { if (Configuration::get('MC_MANUAL_BULK') == 1) { return $this->display(__FILE__, 'multicart_manual_bulk.tpl'); } else { return $this->display(__FILE__, 'multicart_manual.tpl'); } } } } public function isEligiblePage() { if (isset($this->context->controller->php_self) && in_array($this->context->controller->php_self, array('index', 'category', 'search', 'products-comparison', 'manufacturer', 'supplier', 'prices-drop', 'best-sales', 'new-products', 'module-ambjolisearch-jolisearch', 'product', 'cms'))) { return true; } else if (!isset($this->context->controller->php_self) && !isset($this->context->controller->page_name)) { return true; } else if (isset($this->context->controller->page_name) && ($this->context->controller->page_name === 'module-flashsales-display' || $this->context->controller->page_name === 'module-prestasearch-search' || $this->context->controller->page_name === 'module-pm_advancedsearch4-searchresults' || $this->context->controller->page_name === 'module-dorblockwishlist-dorwishlist' || $this->context->controller->page_name === 'module-wtblocksearch-catesearch')) { return true; } return false; } public function renderForm() { $fields_form = array(); /* array( 'id' => 'displayECPD', 'name' => $this->l('Custom displayECPD hook')), array( 'type' => 'html', 'name' => 'customhook', 'label' => $this->l('Custom Hook Setup'), 'html_content' => $this->setCustomHook(), ),*/ $fields_form[1] = array( 'form' => array( 'legend' => array( 'title' => $this->l('Settings'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'switch', 'label' => $this->l('Ajax Cart'), 'name' => 'PS_EASY_CART_AJAX', 'is_bool' => true, 'desc' => '<ol><li>'.$this->l('YES :: Add to Cart button will NOT be displayed. Instantly add/remove/change product quantity in Cart as you click on +/-/update quantity in text box').'</li><li>'.$this->l('NO :: Add to Cart icon will be displayed. Add/remove/change product quantity only up on Click of Add to Cart icon').'</li></ol>', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'switch', 'label' => $this->l('Use this module for products With NO combinations'), 'name' => 'MC_APPLY_FOR_SINGLE', 'is_bool' => true, 'desc' => '<ol><li>'.$this->l('YES: Use this module for products With NO combinations / simple products') .'</li><li>'.$this->l('NO: This module will NOT display +/-/qty block for products With NO combinations / simple products').'</li></ol>', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'switch', 'label' => $this->l('Use this module for products WITH combinations'), 'name' => 'MC_APPLY_FOR_COMB', 'is_bool' => true, 'desc' => '<ol><li>'.$this->l('YES: Use this module for products With combinations / variants') .'</li><li>'.$this->l('NO: This module will NOT display +/-/qty block for products With combinations / variants').'</li></ol>', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'switch', 'label' => $this->l('Add multiple combinations of same product in single click'), 'name' => 'MC_MANUAL_BULK', 'is_bool' => true, 'desc' => '<ol><li>'.$this->l('YES :: Add to Cart button will add all variants to Cart based on the quantity entered in the corresponding Quanitity text box. In one click, multiple combinations of the same product shall be added to cart.').'</li><li>'.$this->l('NO :: Add to Cart icon adds that particular combination only').'</li></ol>', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'switch', 'label' => $this->l('Pre-load combinations in Product Listing'), 'name' => 'MC_DISPLAY_COMB_DIRECTLY', 'is_bool' => true, 'desc' => '<ol><li>'.$this->l('YES: displays combinations as drop down for each product. PRE_LOADS combinations. Only limited details can be displayed in the Drop down.') .'</li><li>'.$this->l('NO: displays combinations in pop-up window, on click of "+/-/Qty text box" of the respective product. Loads combinations, only ON REQUEST. Additional details of Combination can be viewed. Product Listing page loads faster as Combinations are NOT Pre-Loaded').'</li></ol>', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'select', 'label' => $this->l('Exactly, where do you want Combinations to be displayed for each product in Product Listing'), 'name' => 'EASYCART_PROD_COMB_HOOK', 'options' => array( 'query' => $this->getCombinationsHooks(), 'id' => 'id', 'name' => 'name' ) ), array( 'type' => 'switch', 'label' => $this->l('Display +/-/Qty Add to Cart Block in Product Details Page for a Simple Product (NO Variants)'), 'name' => 'MC_PD_SIMPLE_ADD_TO_CART', 'desc' => '<ol><li>'.$this->l('YES :: +/-/Qty text box - block will be displayed in addition to the default Add to Cart button.').'</li><li>'.$this->l('NO :: Additional +/-/Qty text box - block will NOT be displayed - Default behavior').'</li></ol>', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'switch', 'label' => $this->l('Hide default Add to Cart button and Variants block in Product Details Page'), 'name' => 'MC_PD_HIDE_DEFAULT_CART', 'desc' => '<ol><li>'.$this->l('YES :: Make sure the previous field is set to YES. This will enable either Default / Module add to cart button is always present in the Product Details page').'</li></ol>', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'select', 'label' => $this->l('Product Details Page:: Where do you want Combinations display in Individual Product Details Page'), 'name' => 'MC_COMB_DISPLAY_HOOK', 'options' => array( 'query' => array( array( 'id' => 'displayProductAdditionalInfo', 'name' => $this->l('Display Product Additional Info')), array( 'id' => 'displayReassurance', 'name' => $this->l('Display Reassurance Block')), array( 'id' => 'displayAfterProductThumbs', 'name' => $this->l('Display After Product Thumbs')), array( 'id' => 'displayAdminProductsExtra', 'name' => $this->l('Display Admin Product Extra')), array( 'id' => 'donotdisplay', 'name' => $this->l('Do Not Display')), ), 'id' => 'id', 'name' => 'name' ) ), array( 'type' => 'switch', 'label' => $this->l('Display minimum quantity required for each product in Product Listing'), 'name' => 'MC_MIN_QTY_TEXT_DISPLAY', 'is_bool' => true, 'desc' => $this->l('Display minimum quantity required to be added to Cart, only if minimum quantity is more than 1'), 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'switch', 'label' => $this->l('Display Out of stock Combinations in Product Listing drop down'), 'name' => 'MC_DISPLAY_COMB_OOS', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'switch', 'label' => $this->l('Add to Cart by "Multiples of Minimum Quantity"'), 'name' => 'MC_VARIANT_CART_TEXT_DISPLAY', 'is_bool' => true, 'desc' => '<ol><li>'.$this->l('YES :: Increament product quantity as multiples of Product Minimum Quantity. Best for B2B / wholesalers').'</li><li>'.$this->l('NO :: Increament product quantity always by 1 after Product Minimum Quantity. Best for B2C / Consumers').'</li></ol>', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'switch', 'label' => $this->l('Single Variant. Directly Display + - Qty box instead of Add Variation button"'), 'name' => 'MC_DD_1VARIANT', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), ), 'submit' => array( 'title' => $this->l('Save') ) ), ); $fields_form[2] = array( 'form' => array( 'legend' => array( 'title' => $this->l('Configure Style'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'select', 'label' => $this->l('Highlight Products on Cart'), 'name' => 'MC_PROD_CART_HIGHLIGHT', 'desc' => $this->l('The products added to cart will be highlighted based on the selected option'), 'options' => array( 'query' => array( array( 'id' => 'Product_Box_Color', 'name' => $this->l('Product_Box_Color')), array( 'id' => 'Switch_Button', 'name' => $this->l('Switch_Button')), ), 'id' => 'id', 'name' => 'name' ) ), array( 'type' => 'color', 'label' => $this->l('Highlight Color: Product Box'), 'name' => 'MC_SELECTED_PROD_BOX_COLOR', 'desc' => $this->l('Products added to the cart will be highlighted with this color'), ), array( 'type' => 'switch', 'label' => $this->l('Show stock column in Combinations window'), 'name' => 'MC_HIDE_COMB_STOCK', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'text', 'label' => $this->l('Display remaining quantities when the quantity is lower than. Set 0 to disable this feature'), 'name' => 'MC_DISPLAY_LAST_STOCK', ), array( 'type' => 'switch', 'label' => $this->l('Hide Minimum Quantity column in Combinations window'), 'name' => 'MC_HIDE_COMB_MIN', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'switch', 'label' => $this->l('Display green / red image instead of actual Stock Quantity'), 'name' => 'MC_COMB_STOCK_IMG', 'is_bool' => true, 'desc' => '<ol><li>'.$this->l('YES: Displays green / red image instead of the actual stock quantity.') .'</li><li>'.$this->l('No: Displays actual stock quantity.').'</li></ol>', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'text', 'label' => $this->l('Color of Tick mark (Product in cart highlight color)'), 'desc' => $this->l('Allowed colors are brown, amber, yellow, green, blue, pink, beach, black, bluegreen, brown, darkblue, darkgray, darkgreen, darknavyblue, darkpink, darksandal, fadeblue, floragreen, floarred, floraskyblue, grassgreen, heavyblue, lavender, lightbrown, lightpink, magento, midgray, navyblue, red, sandal, skyblue, white, yellow, yellogreen'), 'name' => 'MC_TICK_COLOR', ), array( 'type' => 'text', 'label' => $this->l('Tick Mark position from bottom of product box. Default is 50'), 'name' => 'MC_TICK_POSITION', ), array( 'type' => 'text', 'label' => $this->l('Width of Tick Mark. Default is 48'), 'name' => 'MC_TICK_WIDTH', ), array( 'type' => 'text', 'label' => $this->l('Height of Tick Mark. Default is 48'), 'name' => 'MC_TICK_HEIGHT', ), array( 'type' => 'text', 'label' => $this->l('Add Variation button drop down width. Default 110 percentage'), 'name' => 'MC_DD_WIDTH', ), array( 'type' => 'text', 'label' => $this->l('Add Variation button drop down - Each Column width. Default 50 pixel'), 'name' => 'MC_DD_COLUMN_GAP', ), array( 'type' => 'text', 'label' => $this->l('Product Details Page. Combinations block width. Default 100 percentage'), 'name' => 'MC_PD_WIDTH', ), array( 'type' => 'text', 'label' => $this->l('Product Details Page. Combinations block each column width. Default 50 pixel'), 'name' => 'MC_PD_COLUMN_GAP', ), array( 'type' => 'switch', 'label' => $this->l('Display Combination - Image Column in Product Details Page'), 'name' => 'MC_PD_IMG_DISPLAY', 'is_bool' => true, 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'text', 'label' => $this->l('Product Details Page. Combinations block - Image width. Default 100 pixel'), 'name' => 'MC_PD_IMG_WIDTH', ), array( 'type' => 'color', 'label' => $this->l('Background Color of "Plus and Minus" buttons'), 'name' => 'MC_PLUSMINUS_BGCOLOR', ), array( 'type' => 'color', 'label' => $this->l('Out Of Stock Background box Color'), 'name' => 'MC_OOS_BOX_COLOR', ), array( 'type' => 'color', 'label' => $this->l('Out Of Stock Label Color'), 'name' => 'MC_OOS_LABEL_COLOR', ), array( 'type' => 'color', 'label' => $this->l('Background Color of Add to Cart shopping cart icon button'), 'name' => 'MC_CART_ICON_BGCOLOR', ), array( 'type' => 'color', 'label' => $this->l('Background Color of "Add to Cart" confirmation pop-up'), 'name' => 'MC_ADDED_TO_CART_BGCOLOR', 'desc' => $this->l('On "Add to cart", confirmation appears at the bottom of the window. Background color will help high-light the success message.'), ), array( 'type' => 'color', 'label' => $this->l('Text color of "Add to Cart" confirmation message'), 'name' => 'MC_ADDED_TO_CART_TXTCOLOR', 'desc' => $this->l('On "Add to cart", confirmation appears at the bottom of the window. Background color will help high-light the success message.'), ), array( 'type' => 'color', 'label' => $this->l('Text color of "Add Variations" button'), 'name' => 'MC_ADD_VARIANT_TXTCOLOR', 'desc' => $this->l('Text Color of "Add Variations" button, in case of Combination products.'), ), ), 'submit' => array( 'title' => $this->l('Save') ) ), ); $fields_form[3] = array( 'form' => array( 'legend' => array( 'title' => $this->l('Product Price Text'), 'icon' => 'icon-cogs' ), 'input' => array( array( 'type' => 'switch', 'label' => $this->l('Display Price Text (Text next to Price)'), 'name' => 'MC_PRICE_TEXT', 'is_bool' => true, 'desc' => '<ol><li>'.$this->l('YES :: You shall define a Text for every Product in "BO>>EC Price Text menu". The Text will be displayed immediately next to the Price of corresponding product.').'</li><li>'.$this->l('NO :: No text will be displayed after Product Price').'</li></ol>', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), ), '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 = 'submitEasyCart'; $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($fields_form); } //public function setCustomHook() //{ // return '{if isset($groups)}<section class="page-product-box"><h3 class="page-product-heading">{l s="Quickly Add Desired Product Here"}</h3>{hook h="displayECPD" mod="easycart"}</section>{/if}'; //} public function getConfigFieldsValues() { return array( 'PS_EASY_CART_AJAX' => (int)Tools::getValue('PS_EASY_CART_AJAX', Configuration::get('PS_EASY_CART_AJAX')), 'MC_PD_SIMPLE_ADD_TO_CART' => (int)Tools::getValue('MC_PD_SIMPLE_ADD_TO_CART', Configuration::get('MC_PD_SIMPLE_ADD_TO_CART')), 'MC_PD_HIDE_DEFAULT_CART' => (int)Tools::getValue('MC_PD_HIDE_DEFAULT_CART', Configuration::get('MC_PD_HIDE_DEFAULT_CART')), 'MC_MANUAL_BULK' => (int)Tools::getValue('MC_MANUAL_BULK', Configuration::get('MC_MANUAL_BULK')), 'MC_PRICE_TEXT' => (int)Tools::getValue('MC_PRICE_TEXT', Configuration::get('MC_PRICE_TEXT')), 'MC_COMB_STOCK_IMG' => (int)Tools::getValue('MC_COMB_STOCK_IMG', Configuration::get('MC_COMB_STOCK_IMG')), 'MC_PROD_CART_HIGHLIGHT' => (string)Tools::getValue('MC_PROD_CART_HIGHLIGHT', Configuration::get('MC_PROD_CART_HIGHLIGHT')), 'MC_SELECTED_PROD_BOX_COLOR' => (string)Tools::getValue('MC_SELECTED_PROD_BOX_COLOR', Configuration::get('MC_SELECTED_PROD_BOX_COLOR')), 'MC_ADDED_TO_CART_BGCOLOR' => (string)Tools::getValue('MC_ADDED_TO_CART_BGCOLOR', Configuration::get('MC_ADDED_TO_CART_BGCOLOR')), 'MC_DISPLAY_COMB_OOS' => (int)Tools::getValue('MC_DISPLAY_COMB_OOS', Configuration::get('MC_DISPLAY_COMB_OOS')), 'MC_OOS_BOX_COLOR' => (string)Tools::getValue('MC_OOS_BOX_COLOR', Configuration::get('MC_OOS_BOX_COLOR')), 'MC_OOS_LABEL_COLOR' => (string)Tools::getValue('MC_OOS_LABEL_COLOR', Configuration::get('MC_OOS_LABEL_COLOR')), 'MC_PLUSMINUS_BGCOLOR' => (string)Tools::getValue('MC_PLUSMINUS_BGCOLOR', Configuration::get('MC_PLUSMINUS_BGCOLOR')), 'MC_TICK_COLOR' => Tools::getValue('MC_TICK_COLOR', Configuration::get('MC_TICK_COLOR')), 'MC_HIDE_COMB_STOCK' => Tools::getValue('MC_HIDE_COMB_STOCK', Configuration::get('MC_HIDE_COMB_STOCK')), 'MC_DISPLAY_LAST_STOCK' => Tools::getValue('MC_DISPLAY_LAST_STOCK', Configuration::get('MC_DISPLAY_LAST_STOCK')), 'MC_HIDE_COMB_MIN' => Tools::getValue('MC_HIDE_COMB_MIN', Configuration::get('MC_HIDE_COMB_MIN')), 'MC_TICK_POSITION' => Tools::getValue('MC_TICK_POSITION', Configuration::get('MC_TICK_POSITION')), 'MC_TICK_WIDTH' => Tools::getValue('MC_TICK_WIDTH', Configuration::get('MC_TICK_WIDTH')), 'MC_TICK_HEIGHT' => Tools::getValue('MC_TICK_HEIGHT', Configuration::get('MC_TICK_HEIGHT')), 'MC_DD_WIDTH' => Tools::getValue('MC_DD_WIDTH', Configuration::get('MC_DD_WIDTH')), 'MC_DD_1VARIANT' => Tools::getValue('MC_DD_1VARIANT', Configuration::get('MC_DD_1VARIANT')), 'MC_DD_COLUMN_GAP' => Tools::getValue('MC_DD_COLUMN_GAP', Configuration::get('MC_DD_COLUMN_GAP')), 'MC_PD_WIDTH' => Tools::getValue('MC_PD_WIDTH', Configuration::get('MC_PD_WIDTH')), 'MC_PD_IMG_WIDTH' => Tools::getValue('MC_PD_IMG_WIDTH', Configuration::get('MC_PD_IMG_WIDTH')), 'MC_PD_IMG_DISPLAY' => Tools::getValue('MC_PD_IMG_DISPLAY', Configuration::get('MC_PD_IMG_DISPLAY')), 'MC_PD_COLUMN_GAP' => Tools::getValue('MC_PD_COLUMN_GAP', Configuration::get('MC_PD_COLUMN_GAP')), 'MC_CART_ICON_BGCOLOR' => (string)Tools::getValue('MC_CART_ICON_BGCOLOR', Configuration::get('MC_CART_ICON_BGCOLOR')), 'MC_ADDED_TO_CART_TXTCOLOR' => (string)Tools::getValue('MC_ADDED_TO_CART_TXTCOLOR', Configuration::get('MC_ADDED_TO_CART_TXTCOLOR')), 'MC_ADD_VARIANT_TXTCOLOR' => (string)Tools::getValue('MC_ADD_VARIANT_TXTCOLOR', Configuration::get('MC_ADD_VARIANT_TXTCOLOR')), 'EASYCART_PROD_COMB_HOOK' => (string)Tools::getValue('EASYCART_PROD_COMB_HOOK', Configuration::get('EASYCART_PROD_COMB_HOOK')), 'MC_MIN_QTY_TEXT_DISPLAY' => (int)Tools::getValue('MC_MIN_QTY_TEXT_DISPLAY', Configuration::get('MC_MIN_QTY_TEXT_DISPLAY')), 'MC_DISPLAY_COMB_DIRECTLY' => (int)Tools::getValue('MC_DISPLAY_COMB_DIRECTLY', Configuration::get('MC_DISPLAY_COMB_DIRECTLY')), 'MC_APPLY_FOR_COMB' => (int)Tools::getValue('MC_APPLY_FOR_COMB', Configuration::get('MC_APPLY_FOR_COMB')), 'MC_APPLY_FOR_SINGLE' => (int)Tools::getValue('MC_APPLY_FOR_SINGLE', Configuration::get('MC_APPLY_FOR_SINGLE')), 'MC_COMB_DISPLAY_HOOK' => (string)Tools::getValue('MC_COMB_DISPLAY_HOOK', Configuration::get('MC_COMB_DISPLAY_HOOK')), 'MC_VARIANT_CART_TEXT_DISPLAY' => (int)Tools::getValue('MC_VARIANT_CART_TEXT_DISPLAY', Configuration::get('MC_VARIANT_CART_TEXT_DISPLAY')), ); } public function hookDisplayProductAdditionalInfo($params) { $id_product = (int)Tools::getValue('id_product'); if ($id_product) { $this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id); $this->assignImages(); $res = $this->assignAttributesGroups(); return $res; } } public function hookDisplayReassurance($params) { $id_product = (int)Tools::getValue('id_product'); if ($id_product) { $this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id); $this->assignImages(); $res = $this->assignAttributesGroups(); return $res; } } public function hookDisplayAfterProductThumbs($params) { $id_product = (int)Tools::getValue('id_product'); if ($id_product) { $this->product = new Product($id_product, true, $this->context->language->id, $this->context->shop->id); $this->assignImages(); $res = $this->assignAttributesGroups(); return $res; } } /* *{if isset($groups)}<section class="page-product-box"><h3 class="page-product-heading">{l s='Quickly Add Desired Product Here'}</h3>{hook h='displayECPD' mod='easycart' }</section>{/if} */ public function hookDisplayECPD($params) { $id_product = (int)Tools::getValue('id_product'); if ($id_product) { $this->product = new Product($id_product, false, $this->context->language->id, $this->context->shop->id); $this->assignImages(); $res = $this->assignAttributesGroups(); return $res; } } protected function assignImages() { $images = $this->product->getImages((int)$this->context->cookie->id_lang); $product_images = array(); if (isset($images[0])) { $this->smarty->assign('mainImage', $images[0]); } foreach ($images as $k => $image) { if ($image['cover']) { $this->smarty->assign('mainImage', $image); $cover = $image; $cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$image['id_image']) : $image['id_image']); $cover['id_image_only'] = (int)$image['id_image']; } $product_images[(int)$image['id_image']] = $image; } if (!isset($cover)) { if (isset($images[0])) { $cover = $images[0]; $cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$images[0]['id_image']) : $images[0]['id_image']); $cover['id_image_only'] = (int)$images[0]['id_image']; } else { $cover = array( 'id_image' => $this->context->language->iso_code.'-default', 'legend' => 'No picture', 'title' => 'No picture' ); } } $size = Image::getSize(ImageType::getFormatedName('large')); $this->smarty->assign(array( 'have_image' => (isset($cover['id_image']) && (int)$cover['id_image'])? array((int)$cover['id_image']) : Product::getCover((int)Tools::getValue('id_product')), 'cover' => $cover, 'imgWidth' => (int)$size['width'], 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'largeSize' => Image::getSize(ImageType::getFormatedName('large')), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'cartSize' => Image::getSize(ImageType::getFormatedName('cart')), 'img_col_dir' => '/img/co/', //'priceDisplay' => Product::getTaxCalculationMethod((int)$this->context->cookie->id_customer), 'col_img_dir' => _PS_COL_IMG_DIR_)); if (count($product_images)) { $this->smarty->assign('images', $product_images); } } public function getAttributesGroups($product_id, $id_lang) { if (!Combination::isFeatureActive()) { return array(); } $sql = 'SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, product_attribute_shop.`id_product_attribute`, IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`price`, product_attribute_shop.`ecotax`, product_attribute_shop.`weight`, product_attribute_shop.`default_on`, pa.`reference`, product_attribute_shop.`unit_price_impact`, product_attribute_shop.`minimal_quantity`, product_attribute_shop.`available_date`, ag.`group_type` FROM `'._DB_PREFIX_.'product_attribute` pa '.Shop::addSqlAssociation('product_attribute', 'pa').' '.Product::sqlStock('pa', 'pa').' LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`) LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`) LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`) LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute`) LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group`) '.Shop::addSqlAssociation('attribute', 'a').' WHERE pa.`id_product` = '.(int)$product_id.' AND al.`id_lang` = '.(int)$id_lang.' AND agl.`id_lang` = '.(int)$id_lang.$this->addOOSCondition().' GROUP BY id_attribute_group, id_product_attribute ORDER BY ag.`position` ASC, a.`position` ASC, pac.`id_product_attribute` ASC, agl.`name` ASC'; //print_r($sql); //die(); return Db::getInstance()->executeS($sql); } protected function assignAttributesGroups() { $colors = array(); $groups = array(); $this->smarty->assign(array('PS_EASY_CART_AJAX' => Configuration::get('PS_EASY_CART_AJAX'), 'MC_COMB_STOCK_IMG' => Configuration::get('MC_COMB_STOCK_IMG'), 'MC_MIN_QTY_TEXT_DISPLAY' => Configuration::get('MC_MIN_QTY_TEXT_DISPLAY'), 'MC_VARIANT_CART_TEXT_DISPLAY' => Configuration::get('MC_VARIANT_CART_TEXT_DISPLAY'), 'MC_ADDED_TO_CART_BGCOLOR' => Configuration::get('MC_ADDED_TO_CART_BGCOLOR'), 'MC_PLUSMINUS_BGCOLOR' => Configuration::get('MC_PLUSMINUS_BGCOLOR'), 'MC_CART_ICON_BGCOLOR' => Configuration::get('MC_CART_ICON_BGCOLOR'), 'MC_TICK_COLOR' => Configuration::get('MC_TICK_COLOR'), 'MC_HIDE_COMB_STOCK' => Configuration::get('MC_HIDE_COMB_STOCK'), 'MC_DISPLAY_LAST_STOCK' => Configuration::get('MC_DISPLAY_LAST_STOCK'), 'MC_HIDE_COMB_MIN' => Configuration::get('MC_HIDE_COMB_MIN'), 'MC_TICK_POSITION' => Configuration::get('MC_TICK_POSITION'), 'MC_TICK_WIDTH' => Configuration::get('MC_TICK_WIDTH'), 'MC_TICK_HEIGHT' => Configuration::get('MC_TICK_HEIGHT'), 'MC_ADDED_TO_CART_TXTCOLOR' => Configuration::get('MC_ADDED_TO_CART_TXTCOLOR'), 'MC_ADD_VARIANT_TXTCOLOR' => Configuration::get('MC_ADD_VARIANT_TXTCOLOR'), 'MC_SELECTED_PROD_BOX_COLOR' => Configuration::get('MC_SELECTED_PROD_BOX_COLOR'), 'MC_PD_WIDTH' => Configuration::get('MC_PD_WIDTH'), 'MC_PD_COLUMN_GAP' => Configuration::get('MC_PD_COLUMN_GAP'), 'MC_PD_IMG_WIDTH' => Configuration::get('MC_PD_IMG_WIDTH'), 'MC_PD_IMG_DISPLAY' => Configuration::get('MC_PD_IMG_DISPLAY'), 'is_catalog' => (bool) Configuration::isCatalogMode(), 'priceDisplay' => Product::getTaxCalculationMethod((int) $this->context->cookie->id_customer), 'show_prices' => (bool) Configuration::showPrices())); $attributes_groups = $this->getAttributesGroups($this->product->id, Context::getContext()->language->id); $allow_oosp = Product::isAvailableWhenOutOfStock((int)$this->product->out_of_stock); if (is_array($attributes_groups) && $attributes_groups) { $mc_cart_prod_qty = Context::getContext()->cart->getProducts(); $mc_product_attr_qty = array(); $mc_product_present_incart = false; if (is_array($mc_cart_prod_qty) && $mc_cart_prod_qty) { foreach ($mc_cart_prod_qty as $mc_cart_prod_item) { if ($this->product->id == $mc_cart_prod_item['id_product']) { $mc_product_present_incart = true; $mc_product_attr_qty[$mc_cart_prod_item['id_product_attribute']] = $mc_cart_prod_item['cart_quantity']; } } } $combination_images = $this->product->getCombinationImages($this->context->language->id); $combination_prices_set = array(); $combinations = array(); foreach ($attributes_groups as $k => $row) { if (isset($row['is_color_group']) && $row['is_color_group'] && (isset($row['attribute_color']) && $row['attribute_color']) || (file_exists(_PS_COL_IMG_DIR_.$row['id_attribute'].'.jpg'))) { $colors[$row['id_attribute']]['value'] = $row['attribute_color']; $colors[$row['id_attribute']]['name'] = $row['attribute_name']; if (!isset($colors[$row['id_attribute']]['attributes_quantity'])) { $colors[$row['id_attribute']]['attributes_quantity'] = 0; } $colors[$row['id_attribute']]['attributes_quantity'] += (int)$row['quantity']; } if (!isset($groups[$row['id_attribute_group']])) { $groups[$row['id_attribute_group']] = array( 'group_name' => $row['group_name'], 'name' => $row['public_group_name'], 'group_type' => $row['group_type'], 'default' => -1, ); } $groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name']; if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1) { $groups[$row['id_attribute_group']]['default'] = (int)$row['id_attribute']; } if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']])) { $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0; } $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int)$row['quantity']; $combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name']; $combinations[$row['id_product_attribute']]['id_attribute'][$row['id_attribute_group']] = (int)$row['id_attribute']; $combinations[$row['id_product_attribute']]['attributes'][] = (int)$row['id_attribute']; $combinations[$row['id_product_attribute']]['price'] = (float)$row['price']; if ($mc_product_present_incart && isset($mc_product_attr_qty[(int)$row['id_product_attribute']])) { $combinations[$row['id_product_attribute']]['cart_quantity'] = (int)$mc_product_attr_qty[(int)$row['id_product_attribute']]; } else { $combinations[$row['id_product_attribute']]['cart_quantity'] = 0; } // Call getPriceStatic in order to set $combination_specific_price $combination_specific_price = array(); if (!isset($combination_prices_set[(int)$row['id_product_attribute']])) { Product::getPriceStatic((int)$this->product->id, Product::$_taxCalculationMethod == PS_TAX_INC, $row['id_product_attribute'], 6, null, false, true, 1, false, null, null, null, $combination_specific_price); $combination_prices_set[(int)$row['id_product_attribute']] = true; $combinations[$row['id_product_attribute']]['specific_price'] = $combination_specific_price; } $combinations[$row['id_product_attribute']]['ecotax'] = (float)$row['ecotax']; $combinations[$row['id_product_attribute']]['weight'] = (float)$row['weight']; $combinations[$row['id_product_attribute']]['quantity'] = (int)$row['quantity']; $combinations[$row['id_product_attribute']]['reference'] = $row['reference']; $combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact']; $combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity']; if ($row['available_date'] != '0000-00-00' && Validate::isDate($row['available_date'])) { $combinations[$row['id_product_attribute']]['available_date'] = $row['available_date']; $combinations[$row['id_product_attribute']]['date_formatted'] = Tools::displayDate($row['available_date']); } else { $combinations[$row['id_product_attribute']]['available_date'] = $combinations[$row['id_product_attribute']]['date_formatted'] = ''; } if (!isset($combination_images[$row['id_product_attribute']][0]['id_image'])) { $combinations[$row['id_product_attribute']]['id_image'] = -1; } else { $combinations[$row['id_product_attribute']]['id_image'] = $id_image = (int)$combination_images[$row['id_product_attribute']][0]['id_image']; if ($row['default_on']) { if (isset($this->smarty->tpl_vars['cover']->value)) { $current_cover = $this->smarty->tpl_vars['cover']->value; } if (is_array($combination_images[$row['id_product_attribute']])) { foreach ($combination_images[$row['id_product_attribute']] as $tmp) { if ($tmp['id_image'] == $current_cover['id_image']) { $combinations[$row['id_product_attribute']]['id_image'] = $id_image = (int)$tmp['id_image']; break; } } } if ($id_image > 0) { if (isset($this->smarty->tpl_vars['images']->value)) { $product_images = $this->smarty->tpl_vars['images']->value; } if (isset($product_images) && is_array($product_images) && isset($product_images[$id_image])) { $product_images[$id_image]['cover'] = 1; $this->smarty->assign('mainImage', $product_images[$id_image]); if (count($product_images)) { $this->smarty->assign('images', $product_images); } } if (isset($this->smarty->tpl_vars['cover']->value)) { $cover = $this->smarty->tpl_vars['cover']->value; } if (isset($cover) && is_array($cover) && isset($product_images) && is_array($product_images)) { $product_images[$cover['id_image']]['cover'] = 0; if (isset($product_images[$id_image])) { $cover = $product_images[$id_image]; } $cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$id_image) : (int)$id_image); $cover['id_image_only'] = (int)$id_image; $this->smarty->assign('cover', $cover); } } } } } // wash attributes list (if some attributes are unavailables and if allowed to wash it) if (!$allow_oosp && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) { foreach ($groups as &$group) { foreach ($group['attributes_quantity'] as $key => &$quantity) { if ($quantity <= 0) { unset($group['attributes'][$key]); } } } foreach ($colors as $key => $color) { if ($color['attributes_quantity'] <= 0) { unset($colors[$key]); } } } foreach ($combinations as $id_product_attribute => $comb) { $attribute_list = ''; foreach ($comb['attributes'] as $id_attribute) { $attribute_list .= '\''.(int)$id_attribute.'\','; } $attribute_list = rtrim($attribute_list, ','); $combinations[$id_product_attribute]['list'] = $attribute_list; } $this->smarty->assign(array( 'groups' => $groups, 'colors' => (count($colors)) ? $colors : false, 'combinations' => $combinations, 'combinationImages' => $combination_images, 'allow_oosp' => $allow_oosp, 'product' => $this->product, 'img_col_dir' => '/img/co/', 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'col_img_dir' => _PS_COL_IMG_DIR_, 'cartcombqty' => 1, )); if ((int)Configuration::get('PS_EASY_CART_AJAX')) { return $this->display(__file__, 'views/templates/front/combination.tpl'); } else { return $this->display(__file__, 'views/templates/front/combination_manual.tpl'); } } else { $mc_cart_prod_qty = Context::getContext()->cart->getProducts(); $mc_product_qty = array(); $mc_product_present_incart = false; if (is_array($mc_cart_prod_qty) && $mc_cart_prod_qty) { foreach ($mc_cart_prod_qty as $mc_cart_prod_item) { if ($this->product->id == $mc_cart_prod_item['id_product']) { $mc_product_present_incart = true; $mc_product_qty[$mc_cart_prod_item['id_product']] = $mc_cart_prod_item['cart_quantity']; } } } if ((int)Configuration::get('MC_PD_SIMPLE_ADD_TO_CART')) { $this->smarty->assign(array( 'product' => $this->product, 'qty_cart_products' => (!empty($mc_product_qty)) ? $mc_product_qty : null, 'in_cart' => $mc_product_present_incart, 'allow_oosp' => $allow_oosp, 'product_quantity' => StockAvailable::getQuantityAvailableByProduct($this->product->id, 0), )); if ((int)Configuration::get('PS_EASY_CART_AJAX')) { return $this->display(__file__, 'views/templates/front/pd_simple.tpl'); } else { return $this->display(__file__, 'views/templates/front/pd_simple_manual.tpl'); } } else { return false; } } } public function getProductCombinations($productArray) { $id_product = $productArray['id_product']; /* This patch should be enabled if NdkCf Customize Field module is used $id_category_default = (int)productArray['id_category_default']; $is_required = NdkCf::isRequiredCustomization($id_product, (int)$id_category_default); if ($is_required) { return false; } */ $mc_cart_prod_qty = Context::getContext()->cart->getProducts(); $mc_product_total_incart = 0; $mc_product_present_incart = false; $mc_product_attr_qty = array(); if (is_array($mc_cart_prod_qty) && $mc_cart_prod_qty) { foreach ($mc_cart_prod_qty as $mc_cart_prod_item) { if ($id_product == $mc_cart_prod_item['id_product']) { $mc_product_present_incart = true; $mc_product_total_incart = $mc_product_total_incart + $mc_cart_prod_item['cart_quantity']; $mc_product_attr_qty[$mc_cart_prod_item['id_product_attribute']] = $mc_cart_prod_item['cart_quantity']; } } } $productArray['mc_product_total_incart'] = $mc_product_total_incart; $this->context->smarty->assign(array('PS_EASY_CART_AJAX' => Configuration::get('PS_EASY_CART_AJAX'), 'MC_OOS_BOX_COLOR' => Configuration::get('MC_OOS_BOX_COLOR'), 'MC_OOS_LABEL_COLOR' => Configuration::get('MC_OOS_LABEL_COLOR'), 'MC_MIN_QTY_TEXT_DISPLAY' => Configuration::get('MC_MIN_QTY_TEXT_DISPLAY'), 'MC_COMB_STOCK_IMG' => Configuration::get('MC_COMB_STOCK_IMG'), 'MC_VARIANT_CART_TEXT_DISPLAY' => Configuration::get('MC_VARIANT_CART_TEXT_DISPLAY'), 'MC_ADDED_TO_CART_BGCOLOR' => Configuration::get('MC_ADDED_TO_CART_BGCOLOR'), 'MC_PLUSMINUS_BGCOLOR' => Configuration::get('MC_PLUSMINUS_BGCOLOR'), 'MC_TICK_COLOR' => Configuration::get('MC_TICK_COLOR'), 'MC_HIDE_COMB_STOCK' => Configuration::get('MC_HIDE_COMB_STOCK'), 'MC_DISPLAY_LAST_STOCK' => Configuration::get('MC_DISPLAY_LAST_STOCK'), 'MC_HIDE_COMB_MIN' => Configuration::get('MC_HIDE_COMB_MIN'), 'MC_TICK_POSITION' => Configuration::get('MC_TICK_POSITION'), 'MC_TICK_WIDTH' => Configuration::get('MC_TICK_WIDTH'), 'MC_TICK_HEIGHT' => Configuration::get('MC_TICK_HEIGHT'), 'MC_CART_ICON_BGCOLOR' => Configuration::get('MC_CART_ICON_BGCOLOR'), 'MC_ADDED_TO_CART_TXTCOLOR' => Configuration::get('MC_ADDED_TO_CART_TXTCOLOR'), 'MC_ADD_VARIANT_TXTCOLOR' => Configuration::get('MC_ADD_VARIANT_TXTCOLOR'), 'MC_DD_WIDTH' => Configuration::get('MC_DD_WIDTH'), 'MC_DD_1VARIANT' => Configuration::get('MC_DD_1VARIANT'), 'MC_DD_COLUMN_GAP' => Configuration::get('MC_DD_COLUMN_GAP'), 'MC_SELECTED_PROD_BOX_COLOR' => Configuration::get('MC_SELECTED_PROD_BOX_COLOR'), 'is_catalog' => (bool) Configuration::isCatalogMode(), 'priceDisplay' => Product::getTaxCalculationMethod((int) $this->context->cookie->id_customer), 'allow_oosp' => $productArray['allow_oosp'], 'show_prices' => (bool) Configuration::showPrices())); $MC_DISPLAY_COMB_DIRECTLY = Configuration::get('MC_DISPLAY_COMB_DIRECTLY'); if ($MC_DISPLAY_COMB_DIRECTLY) { /*$pack = $this->isPack($id_product); if ($pack) { $this->context->smarty->assign(array( 'product' => $productArray, )); if ((int)Configuration::get('PS_EASY_CART_AJAX')) { return $this->context->smarty->fetch('module:easycart/views/templates/front/packajax.tpl'); } else { return $this->context->smarty->fetch('module:easycart/views/templates/front/packmanual.tpl'); } }*/ $attributes_groups = $this->getCombinationHookAttributesGroups($id_product, $this->context->language->id); if (is_array($attributes_groups) && $attributes_groups) { if (Configuration::get('MC_APPLY_FOR_COMB')) { $product = new Product($id_product, false, $this->context->language->id, $this->context->shop->id); $colors = array(); $groups = array(); $allow_oosp = Product::isAvailableWhenOutOfStock((int)$product->out_of_stock); //$combination_prices_set = array(); $combinations = array(); foreach ($attributes_groups as $k => $row) { if (isset($row['is_color_group']) && $row['is_color_group'] && (isset($row['attribute_color']) && $row['attribute_color']) || (file_exists(_PS_COL_IMG_DIR_.$row['id_attribute'].'.jpg'))) { $colors[$row['id_attribute']]['value'] = $row['attribute_color']; $colors[$row['id_attribute']]['name'] = $row['attribute_name']; if (!isset($colors[$row['id_attribute']]['attributes_quantity'])) { $colors[$row['id_attribute']]['attributes_quantity'] = 0; } $colors[$row['id_attribute']]['attributes_quantity'] += (int)$row['quantity']; } if (!isset($groups[$row['id_attribute_group']])) { $groups[$row['id_attribute_group']] = array( 'group_name' => $row['group_name'], 'name' => $row['public_group_name'], 'group_type' => $row['group_type'], 'default' => -1, ); } $groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name']; if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1) { $groups[$row['id_attribute_group']]['default'] = (int)$row['id_attribute']; } if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']])) { $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0; } $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int)$row['quantity']; $combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name']; $combinations[$row['id_product_attribute']]['id_attribute'][$row['id_attribute_group']] = (int)$row['id_attribute']; $combinations[$row['id_product_attribute']]['attributes'][] = (int)$row['id_attribute']; $combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity']; if ($mc_product_present_incart && isset($mc_product_attr_qty[(int)$row['id_product_attribute']])) { $combinations[$row['id_product_attribute']]['cart_quantity'] = (int)$mc_product_attr_qty[(int)$row['id_product_attribute']]; } else { $combinations[$row['id_product_attribute']]['cart_quantity'] = 0; } $combinations[$row['id_product_attribute']]['quantity'] = (int)$row['quantity']; } // wash attributes list (if some attributes are unavailables and if allowed to wash it) if (!$productArray['allow_oosp'] && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0) { foreach ($groups as &$group) { foreach ($group['attributes_quantity'] as $key => &$quantity) { if ($quantity <= 0) { unset($group['attributes'][$key]); } } } foreach ($colors as $key => $color) { if ($color['attributes_quantity'] <= 0) { unset($colors[$key]); } } } foreach ($combinations as $id_product_attribute => $comb) { $attribute_list = ''; foreach ($comb['attributes'] as $id_attribute) { $attribute_list .= '\''.(int)$id_attribute.'\','; } $attribute_list = rtrim($attribute_list, ','); $combinations[$id_product_attribute]['list'] = $attribute_list; } $this->context->smarty->assign(array( 'groups' => $groups, 'colors' => (count($colors)) ? $colors : false, 'combinations' => $combinations, 'product' => $product, 'productArray' => $productArray, 'img_col_dir' => '/img/co/', 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'col_img_dir' => _PS_COL_IMG_DIR_, 'cartcombqty' => 1, )); if ((int)Configuration::get('PS_EASY_CART_AJAX')) { return $this->context->smarty->fetch('module:easycart/views/templates/front/combination_hook.tpl'); } else { //return $this->context->smarty->fetch('module:easycart/views/templates/front/combination_hook_manual_bulk.tpl'); return $this->context->smarty->fetch('module:easycart/views/templates/front/combination_hook_manual.tpl'); } } } else if ((int)Configuration::get('MC_APPLY_FOR_SINGLE')) { $totalQuantity = $this->getQuantityAvailableByProduct($id_product); $productArray['quantity'] = $totalQuantity; $this->context->smarty->assign(array( 'product' => $productArray, )); if ((int)Configuration::get('PS_EASY_CART_AJAX')) { return $this->context->smarty->fetch('module:easycart/views/templates/front/directaddtocartajaxsnippet.tpl'); } else { return $this->context->smarty->fetch('module:easycart/views/templates/front/directaddtocartmanualsnippet.tpl'); } } } else if ((int)Configuration::get('MC_APPLY_FOR_SINGLE')) { $totalQuantity = $this->getQuantityAvailableByProduct($id_product); $productArray['quantity'] = $totalQuantity; $this->context->smarty->assign(array( 'product' => $productArray, )); if ((int)Configuration::get('PS_EASY_CART_AJAX')) { return $this->context->smarty->fetch('module:easycart/views/templates/front/directaddtocartajaxsnippet.tpl'); } else { return $this->context->smarty->fetch('module:easycart/views/templates/front/directaddtocartmanualsnippet.tpl'); } } } public function isPack($id_pack) { $sql = 'SELECT `id_pack` FROM `'._DB_PREFIX_.'pm_advancedpack` WHERE `id_pack` = '.(int)$id_pack; return Db::getInstance()->executeS($sql); } public function getQuantityAvailableByProduct($id_product = null, $id_shop = null) { $query = new DbQuery(); $query->select('SUM(quantity)'); $query->from('stock_available'); $query->where('id_product = ' . (int) $id_product); $query = StockAvailable::addSqlShopRestriction($query, $id_shop); $result = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query); return $result; } public function getCombinationHookAttributesGroups($product_id, $id_lang) { $sql = 'SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, product_attribute_shop.`id_product_attribute`, IFNULL(stock.quantity, 0) as quantity, product_attribute_shop.`default_on`, product_attribute_shop.`minimal_quantity`, ag.`group_type` FROM `'._DB_PREFIX_.'product_attribute` pa '.Shop::addSqlAssociation('product_attribute', 'pa').' '.Product::sqlStock('pa', 'pa').' LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`) LEFT JOIN `'._DB_PREFIX_.'attribute` a ON (a.`id_attribute` = pac.`id_attribute`) LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON (ag.`id_attribute_group` = a.`id_attribute_group`) LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (a.`id_attribute` = al.`id_attribute`) LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON (ag.`id_attribute_group` = agl.`id_attribute_group`) '.Shop::addSqlAssociation('attribute', 'a').' WHERE pa.`id_product` = '.(int)$product_id.' AND al.`id_lang` = '.(int)$id_lang.' AND agl.`id_lang` = '.(int)$id_lang.$this->addOOSCondition().' GROUP BY id_attribute_group, id_product_attribute ORDER BY ag.`position` ASC, a.`position` ASC, pac.`id_product_attribute` ASC, agl.`name` ASC'; return Db::getInstance()->executeS($sql); } public function addOOSCondition() { $MC_DISPLAY_COMB_OOS = Configuration::get('MC_DISPLAY_COMB_OOS'); if (!$MC_DISPLAY_COMB_OOS) { return " AND stock.quantity > 0 "; } else { return ""; } } }
💾 保存文件
← 返回文件管理器