diff --git a/admin-dev/tabs/AdminCarriers.php b/admin-dev/tabs/AdminCarriers.php index f90672528..e6be467d3 100644 --- a/admin-dev/tabs/AdminCarriers.php +++ b/admin-dev/tabs/AdminCarriers.php @@ -42,12 +42,15 @@ class AdminCarriers extends AdminTab $this->fieldImageSettings = array('name' => 'logo', 'dir' => 's'); $this->fieldsDisplay = array( - 'id_carrier' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'name' => array('title' => $this->l('Name'), 'width' => 100), - 'logo' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 's', 'orderby' => false, 'search' => false), - 'delay' => array('title' => $this->l('Delay'), 'width' => 300, 'orderby' => false), - 'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), - 'is_free' => array('title' => $this->l('Is Free'), 'align' => 'center', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif', 'default' => 'disabled.gif'), 'type' => 'bool', 'orderby' => false)); + 'id_carrier' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), + 'name' => array('title' => $this->l('Name'), 'width' => 100), + 'logo' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 's', 'orderby' => false, 'search' => false), + 'delay' => array('title' => $this->l('Delay'), 'width' => 300, 'orderby' => false), + 'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), + 'is_free' => array('title' => $this->l('Is Free'), 'align' => 'center', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif', 'default' => 'disabled.gif'), 'type' => 'bool', 'orderby' => false) + ); + + $this->_group = 'GROUP BY a.id_carrier'; $this->optionTitle = $this->l('Carrier options'); $this->_fieldsOptions = array( diff --git a/admin-dev/tabs/AdminDiscounts.php b/admin-dev/tabs/AdminDiscounts.php index 4dd8d4ad7..246ae44d6 100644 --- a/admin-dev/tabs/AdminDiscounts.php +++ b/admin-dev/tabs/AdminDiscounts.php @@ -36,9 +36,9 @@ class AdminDiscounts extends AdminTab $this->edit = true; $this->delete = true; $this->_select = 'dtl.`name` AS discount_type, s.name shop_name, - IF(a.id_discount_type = 1, CONCAT(a.value, " %"), - IF(a.id_discount_type = 2, CONCAT(a.value, " ", c.sign), - "--")) as strvalue'; + IF(a.id_discount_type = 1, CONCAT(a.value, " %"), + IF(a.id_discount_type = 2, CONCAT(a.value, " ", c.sign), + "--")) as strvalue'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'currency` c ON (c.`id_currency` = a.`id_currency`) LEFT JOIN `'._DB_PREFIX_.'discount_type` dt ON (dt.`id_discount_type` = a.`id_discount_type`) LEFT JOIN `'._DB_PREFIX_.'shop` s ON (s.`id_shop` = a.`id_shop`) @@ -50,19 +50,20 @@ class AdminDiscounts extends AdminTab $typesArray[$type['id_discount_type']] = $type['name']; $this->fieldsDisplay = array( - 'id_discount' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'name' => array('title' => $this->l('Code'), 'width' => 85, 'prefix' => '', 'suffix' => '', 'filter_key' => 'a!name'), - 'shop_name' => array('title' => $this->l('Shop'), 'width' => 85, 'filter_key' => 's!name'), - 'description' => array('title' => $this->l('Description'), 'width' => 100, 'filter_key' => 'b!description'), - 'discount_type' => array('title' => $this->l('Type'), 'type' => 'select', 'select' => $typesArray, 'filter_key' => 'dt!id_discount_type'), - 'strvalue' => array('title' => $this->l('Value'), 'width' => 50, 'align' => 'right', 'filter_key' => 'a!value'), - 'quantity' => array('title' => $this->l('Qty'), 'width' => 40, 'align' => 'right'), - 'date_to' => array('title' => $this->l('To'), 'width' => 60, 'type' => 'date', 'align' => 'right'), - 'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)); + 'id_discount' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), + 'name' => array('title' => $this->l('Code'), 'width' => 85, 'prefix' => '', 'suffix' => '', 'filter_key' => 'a!name'), + 'shop_name' => array('title' => $this->l('Shop'), 'width' => 85, 'filter_key' => 's!name'), + 'description' => array('title' => $this->l('Description'), 'width' => 100, 'filter_key' => 'b!description'), + 'discount_type' => array('title' => $this->l('Type'), 'type' => 'select', 'select' => $typesArray, 'filter_key' => 'dt!id_discount_type'), + 'strvalue' => array('title' => $this->l('Value'), 'width' => 50, 'align' => 'right', 'filter_key' => 'a!value'), + 'quantity' => array('title' => $this->l('Qty'), 'width' => 40, 'align' => 'right'), + 'date_to' => array('title' => $this->l('To'), 'width' => 60, 'type' => 'date', 'align' => 'right'), + 'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), + ); $this->optionTitle = $this->l('Discounts options'); $this->_fieldsOptions = array( - 'PS_VOUCHERS' => array('title' => $this->l('Enable vouchers:'), 'desc' => $this->l('Allow the use of vouchers in shop'), 'cast' => 'intval', 'type' => 'bool'), + 'PS_VOUCHERS' => array('title' => $this->l('Enable vouchers:'), 'desc' => $this->l('Allow the use of vouchers in shop'), 'cast' => 'intval', 'type' => 'bool'), ); parent::__construct(); } @@ -445,8 +446,14 @@ class AdminDiscounts extends AdminTab getFieldValue($obj, 'active') ? 'checked="checked" ' : '').'/>

'.$this->l('Enable or disable voucher').'

- -
+
'; + if (Tools::isMultiShopActivated()) + { + echo '
'; + $this->displayAssoShop(); + echo '
'; + } + echo '
* '.$this->l('Required field').'
diff --git a/admin-dev/tabs/AdminShop.php b/admin-dev/tabs/AdminShop.php index 6a37d816f..1254b0446 100755 --- a/admin-dev/tabs/AdminShop.php +++ b/admin-dev/tabs/AdminShop.php @@ -144,6 +144,7 @@ class AdminShop extends AdminTab 'contact' => $this->l('Contact'), 'country' => $this->l('Countries'), 'currency' => $this->l('Currencies'), + 'discount' => $this->l('Discounts'), 'image' => $this->l('Images'), 'lang' => $this->l('Langs'), 'manufacturer' => $this->l('Manufacturers'), diff --git a/classes/AdminTab.php b/classes/AdminTab.php index b7427ec87..8f5fbb191 100644 --- a/classes/AdminTab.php +++ b/classes/AdminTab.php @@ -98,6 +98,8 @@ abstract class AdminTabCore /** @var bool */ public $shopShareDatas = false; + + public $shopAssoName = 'name'; /** @var array Cache for query results */ protected $_list = array(); @@ -275,9 +277,9 @@ abstract class AdminTabCore $this->includeSubTab('display'); $assos_shop = Shop::getAssoTables(); if (isset($assos_shop[$this->table]) AND $assos_shop[$this->table]['type'] == 'shop') - $this->displayAssoShop(); + $this->displayAssoShop($this->shopAssoName); elseif (isset($assos_shop[$this->table]) AND $assos_shop[$this->table]['type'] == 'group_shop') - $this->displayAssoGroupShop(); + $this->displayAssoGroupShop($this->shopAssoName); } } @@ -1971,17 +1973,18 @@ abstract class AdminTabCore $this->l('Click here if you want to modify the main shop domain name').''); } - protected function displayAssoShop($field_name = 'name') + protected function displayAssoShop($field_name = 'name', $selectName = null) { $context = Context::getContext(); if (!Tools::isMultiShopActivated() || (!$this->_object && $context->shop->getContextType() != Shop::CONTEXT_ALL)) return; $shops = Shop::getShops(); - $objects = Db::getInstance()->ExecuteS('SELECT DISTINCT a.`'.pSQL($this->identifier).'`, '.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? 'b' : 'a').'.`'.pSQL($field_name).'` - FROM `'._DB_PREFIX_.pSQL($this->table).'`a '. - (($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' LEFT JOIN `'._DB_PREFIX_.pSQL($this->table).'_lang` b ON (a.`'.pSQL($this->identifier).'`=b.`'.pSQL($this->identifier).'`)' : ''). - ' WHERE 1'.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' AND b.id_lang='.(int)$context->language->id : '').($this->_object ? ' AND a.`'.pSQL($this->identifier).'`='.(int)$this->_object->id : '')); + $sql = 'SELECT DISTINCT a.`'.pSQL($this->identifier).'`, '.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? 'b' : 'a').'.`'.pSQL($field_name).'` + FROM `'._DB_PREFIX_.pSQL($this->table).'`a '. + (($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' LEFT JOIN `'._DB_PREFIX_.pSQL($this->table).'_lang` b ON (a.`'.pSQL($this->identifier).'`=b.`'.pSQL($this->identifier).'`)' : ''). + ' WHERE 1'.(($this->lang AND isset($this->fieldsDisplay[$field_name]['filter_key']) AND $this->fieldsDisplay[$field_name]['filter_key'] == 'b!'.$field_name) ? ' AND b.id_lang='.(int)$context->language->id : '').($this->_object ? ' AND a.`'.pSQL($this->identifier).'`='.(int)$this->_object->id : ''); + $objects = Db::getInstance()->ExecuteS($sql); $assos = array(); $res = Db::getInstance()->ExecuteS('SELECT id_shop, `'.pSQL($this->identifier).'` FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`'); diff --git a/classes/Carrier.php b/classes/Carrier.php index 240888516..13a64d47a 100644 --- a/classes/Carrier.php +++ b/classes/Carrier.php @@ -73,6 +73,8 @@ class CarrierCore extends ObjectModel /** @var boolean Need Range */ public $need_range = 0; + + protected $langMultiShop = true; protected $fieldsRequired = array('name', 'active'); protected $fieldsSize = array('name' => 64); @@ -342,16 +344,16 @@ class CarrierCore extends ObjectModel if ($ids == '') return (array()); } - $sql = ' - SELECT c.*, cl.delay - FROM `'._DB_PREFIX_.'carrier` c - LEFT JOIN `'._DB_PREFIX_.'carrier_lang` cl ON (c.`id_carrier` = cl.`id_carrier` AND cl.`id_lang` = '.(int)($id_lang).') - LEFT JOIN `'._DB_PREFIX_.'carrier_zone` cz ON (cz.`id_carrier` = c.`id_carrier`)'. - ($id_zone ? 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = '.(int)($id_zone).')' : '').' - WHERE c.`deleted` '.($delete ? '= 1' : ' = 0'). - ($active ? ' AND c.`active` = 1' : ''). - ($id_zone ? ' AND cz.`id_zone` = '.(int)($id_zone).' - AND z.`active` = 1 ' : ' '); + + $sql = 'SELECT c.*, cl.delay + FROM `'._DB_PREFIX_.'carrier` c + LEFT JOIN `'._DB_PREFIX_.'carrier_lang` cl ON (c.`id_carrier` = cl.`id_carrier` AND cl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->sqlLang('cl').') + LEFT JOIN `'._DB_PREFIX_.'carrier_zone` cz ON (cz.`id_carrier` = c.`id_carrier`)'. + ($id_zone ? 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = '.(int)$id_zone.')' : '').' + WHERE c.`deleted` = '.($delete ? '1' : '0'). + ($active ? ' AND c.`active` = 1' : ''). + ($id_zone ? ' AND cz.`id_zone` = '.(int)$id_zone.' + AND z.`active` = 1 ' : ' '); switch ($modules_filters) { case 1 : diff --git a/classes/Currency.php b/classes/Currency.php index 7e292e810..40449c240 100644 --- a/classes/Currency.php +++ b/classes/Currency.php @@ -180,14 +180,14 @@ class CurrencyCore extends ObjectModel * * @return array Currencies */ - static public function getCurrencies($object = false, $active = 1, Context $context = null) + static public function getCurrencies($object = false, $active = 1, Shop $shop = null) { - if (!$context) - $context = Context::getContext(); + if (!$shop) + $shop = new Shop(Context::getContext()->shop->getID(true)); $sql = 'SELECT * FROM `'._DB_PREFIX_.'currency` c - '.$context->shop->sqlAsso('currency', 'c', false).' + '.$shop->sqlAsso('currency', 'c', false).' WHERE `deleted` = 0' .($active == 1 ? ' AND c.`active` = 1' : '').' ORDER BY `name` ASC'; diff --git a/classes/Discount.php b/classes/Discount.php index c53d34f0d..1f0688915 100644 --- a/classes/Discount.php +++ b/classes/Discount.php @@ -28,10 +28,6 @@ class DiscountCore extends ObjectModel { public $id; - - public $id_group_shop; - - public $id_shop; /** @var integer Customer id only if discount is reserved */ public $id_customer; @@ -132,8 +128,6 @@ class DiscountCore extends ObjectModel { parent::validateFields(); - $fields['id_group_shop'] = (int)$this->id_group_shop; - $fields['id_shop'] = (int)$this->id_shop; $fields['id_customer'] = (int)($this->id_customer); $fields['id_group'] = (int)($this->id_group); $fields['id_currency'] = (int)($this->id_currency); @@ -260,13 +254,12 @@ class DiscountCore extends ObjectModel public function usedByCustomer($id_customer) { - return Db::getInstance()->getValue(' - SELECT COUNT(*) - FROM `'._DB_PREFIX_.'order_discount` od - LEFT JOIN `'._DB_PREFIX_.'orders` o ON (od.`id_order` = o.`id_order`) - WHERE od.`id_discount` = '.(int)($this->id).' - AND o.`id_customer` = '.(int)($id_customer) - ); + $sql = 'SELECT COUNT(*) + FROM `'._DB_PREFIX_.'order_discount` od + LEFT JOIN `'._DB_PREFIX_.'orders` o ON (od.`id_order` = o.`id_order`) + WHERE od.`id_discount` = '.(int)$this->id.' + AND o.`id_customer` = '.(int)$id_customer; + return Db::getInstance()->getValue($sql); } /** @@ -278,23 +271,25 @@ class DiscountCore extends ObjectModel */ public function getValue($nb_discounts = 0, $order_total_products = 0, $shipping_fees = 0, $idCart = false, $useTax = true, Context $context = null) { + if (!$context) + $context = Context::getContext(); + $totalAmount = 0; - - $cart = new Cart((int)($idCart)); + $cart = new Cart($idCart); if (!Validate::isLoadedObject($cart)) return 0; - if ((!$this->cumulable AND (int)($nb_discounts) > 1) OR !$this->active OR (!$this->quantity AND !$cart->OrderExists())) + if ((!$this->cumulable AND (int)$nb_discounts > 1) OR !$this->active OR (!$this->quantity AND !$cart->OrderExists())) return 0; - if ($this->usedByCustomer((int)($cart->id_customer)) >= $this->quantity_per_user AND !$cart->OrderExists()) + if ($this->usedByCustomer((int)$cart->id_customer) >= $this->quantity_per_user AND !$cart->OrderExists()) return 0; $date_start = strtotime($this->date_from); $date_end = strtotime($this->date_to); if ((time() < $date_start OR time() > $date_end) AND !$cart->OrderExists()) return 0; - if (!$this->availableWithShop(Context::getContext()->shop)) + if (!$this->isAssociatedToShop($context->shop->shopID())) return 0; $products = $cart->getProducts(); $categories = Discount::getCategories((int)$this->id); @@ -322,8 +317,6 @@ class DiscountCore extends ObjectModel /* Absolute value */ case 2: // An "absolute" voucher is available in one currency only - if (!$context) - $context = Context::getContext(); $currency = ((int)$cart->id_currency ? Currency::getCurrencyInstance($cart->id_currency) : $context->currency); if ($this->id_currency != $currency->id) return 0; @@ -439,8 +432,6 @@ class DiscountCore extends ObjectModel $voucher->minimal = (float)($voucher->value); $voucher->active = 1; $voucher->cart_display = 1; - $voucher->id_group_shop = (int)$order->id_group_shop; - $voucher->id_shop = (int)$order->id_shop; $now = time(); $voucher->date_from = date('Y-m-d H:i:s', $now); diff --git a/classes/Shop.php b/classes/Shop.php index b79b3a06a..e65b07964 100644 --- a/classes/Shop.php +++ b/classes/Shop.php @@ -63,6 +63,7 @@ class ShopCore extends ObjectModel 'contact' => array('type' => 'shop'), 'country' => array('type' => 'shop'), 'currency' => array('type' => 'shop'), + 'discount' => array('type' => 'shop'), 'hook_module' => array('type' => 'fk_shop'), 'hook_module_exceptions' => array('type' => 'fk_shop', 'primary' => 'id_hook_module_exceptions'), 'image' => array('type' => 'shop'), diff --git a/install-dev/sql/db.sql b/install-dev/sql/db.sql index 390755710..1fd0f9084 100644 --- a/install-dev/sql/db.sql +++ b/install-dev/sql/db.sql @@ -541,8 +541,6 @@ CREATE TABLE `PREFIX_delivery` ( CREATE TABLE `PREFIX_discount` ( `id_discount` int(10) unsigned NOT NULL auto_increment, - `id_group_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', - `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1', `id_discount_type` int(10) unsigned NOT NULL, `behavior_not_exhausted` TINYINT(3) DEFAULT '1', `id_customer` int(10) unsigned NOT NULL, @@ -562,8 +560,6 @@ CREATE TABLE `PREFIX_discount` ( `date_add` datetime NOT NULL, `date_upd` datetime NOT NULL, PRIMARY KEY (`id_discount`), - KEY `id_group_shop` (`id_group_shop`), - KEY `id_shop` (`id_shop`), KEY `discount_name` (`name`), KEY `discount_customer` (`id_customer`), KEY `id_discount_type` (`id_discount_type`) @@ -1897,4 +1893,11 @@ CREATE TABLE `PREFIX_scene_shop` ( `id_shop` INT( 11 ) UNSIGNED NOT NULL, PRIMARY KEY (`id_scene`, `id_shop`), KEY `id_shop` (`id_shop`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; + +CREATE TABLE `PREFIX_discount_shop` ( +`id_discount` INT( 11 ) UNSIGNED NOT NULL , +`id_shop` INT( 11 ) UNSIGNED NOT NULL, +PRIMARY KEY (`id_discount`, `id_shop`), + KEY `id_shop` (`id_shop`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/install-dev/sql/upgrade/1.5.0.0.sql b/install-dev/sql/upgrade/1.5.0.0.sql index 2f783bbff..0f677eaa3 100755 --- a/install-dev/sql/upgrade/1.5.0.0.sql +++ b/install-dev/sql/upgrade/1.5.0.0.sql @@ -119,9 +119,6 @@ CREATE TABLE `PREFIX_currency_shop` ( ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; INSERT INTO `PREFIX_currency_shop` (id_shop, id_currency) (SELECT 1, id_currency FROM PREFIX_currency); -ALTER TABLE `PREFIX_discount` ADD `id_group_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_discount`, ADD `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_group_shop`; -ALTER TABLE `PREFIX_discount` ADD INDEX `id_group_shop` (`id_group_shop`), ADD INDEX `id_shop` (`id_shop`); - ALTER TABLE `PREFIX_cart` ADD `id_group_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_cart` , ADD `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_group_shop`, ADD INDEX `id_group_shop` (`id_group_shop`), ADD INDEX `id_shop` (`id_shop`); ALTER TABLE `PREFIX_customer` ADD `id_group_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_customer` , ADD `id_shop` INT(11) UNSIGNED NOT NULL DEFAULT '1' AFTER `id_group_shop`, ADD INDEX `id_group_shop` (`id_group_shop`), ADD INDEX `id_shop` (`id_shop`); @@ -312,5 +309,15 @@ CREATE TABLE `PREFIX_scene_shop` ( PRIMARY KEY (`id_scene`, `id_shop`), KEY `id_shop` (`id_shop`) ) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; +INSERT INTO `PREFIX_scene_shop` (id_shop, id_scene) (SELECT 1, id_scene FROM PREFIX_scene); + +CREATE TABLE `PREFIX_discount_shop` ( +`id_discount` INT( 11 ) UNSIGNED NOT NULL , +`id_shop` INT( 11 ) UNSIGNED NOT NULL, +PRIMARY KEY (`id_discount`, `id_shop`), + KEY `id_shop` (`id_shop`) +) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8; +INSERT INTO `PREFIX_discount_shop` (id_shop, id_discount) (SELECT 1, id_discount FROM PREFIX_discount); + /* PHP:create_multistore(); */ diff --git a/modules/blockcurrencies/blockcurrencies.php b/modules/blockcurrencies/blockcurrencies.php index 3158dd6d9..b7dd0366e 100644 --- a/modules/blockcurrencies/blockcurrencies.php +++ b/modules/blockcurrencies/blockcurrencies.php @@ -60,7 +60,7 @@ class BlockCurrencies extends Module if (Configuration::get('PS_CATALOG_MODE')) return ; - $currencies = Currency::getCurrencies(false, 1, $this->context); + $currencies = Currency::getCurrencies(); if (!sizeof($currencies)) return ''; $this->context->smarty->assign('currencies', $currencies); diff --git a/modules/mondialrelay/mondialrelay.php b/modules/mondialrelay/mondialrelay.php index 31f63d30b..81d9c4a1b 100755 --- a/modules/mondialrelay/mondialrelay.php +++ b/modules/mondialrelay/mondialrelay.php @@ -399,13 +399,13 @@ class MondialRelay extends Module SELECT c.*, cl.delay FROM `'._DB_PREFIX_.'mr_method` m LEFT JOIN `'._DB_PREFIX_.'carrier` c ON (c.`id_carrier` = m.`id_carrier` and c.`deleted` = 0) - LEFT JOIN `'._DB_PREFIX_.'carrier_lang` cl ON (c.`id_carrier` = cl.`id_carrier` AND cl.`id_lang` = '.(int)($id_lang).') + LEFT JOIN `'._DB_PREFIX_.'carrier_lang` cl ON (c.`id_carrier` = cl.`id_carrier` AND cl.`id_lang` = '.(int)$id_lang.Context::getContext()->shop->sqlLang('cl').') LEFT JOIN `'._DB_PREFIX_.'carrier_zone` cz ON (cz.`id_carrier` = c.`id_carrier`)'. - ($id_zone ? 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = '.(int)($id_zone).')' : '').' + ($id_zone ? 'LEFT JOIN `'._DB_PREFIX_.'zone` z ON (z.`id_zone` = '.(int)$id_zone.')' : '').' WHERE 1 '. ($id_iso_code ? ' AND m.`mr_Pays_list` LIKE \'%'.pSQL($id_iso_code).'%\'' : ''). ($active ? ' AND c.`active` = 1' : ''). - ($id_zone ? ' AND cz.`id_zone` = '.(int)($id_zone).' + ($id_zone ? ' AND cz.`id_zone` = '.(int)$id_zone.' AND z.`active` = 1' : '').' GROUP BY c.`id_carrier`');