//add payment module restriction when enable country

This commit is contained in:
vAugagneur
2012-10-01 15:40:11 +00:00
parent 1d9e531313
commit 2b917ed3c3
4 changed files with 56 additions and 15 deletions
+26
View File
@@ -344,4 +344,30 @@ class CountryCore extends ObjectModel
return (bool)preg_match($zip_regexp, $zip_code);
}
public static function addModuleRestrictions(array $shops = array(), array $countries = array(), array $modules = array())
{
if (!count($shops))
$shops = Shop::getShops(true, null, true);
if (!count($countries))
$countries = Country::getCountries((int)Context::getContext()->cookie->id_lang);
if (!count($modules))
$modules = Module::getPaymentModules();
$sql = false;
foreach ($shops as $id_shop)
foreach ($countries as $country)
foreach ($modules as $module)
$sql .= '('.(int)$module['id_module'].', '.(int)$id_shop.', '.(int)$country['id_country'].'),';
if ($sql)
{
$sql = 'INSERT IGNORE INTO `'._DB_PREFIX_.'module_country` (`id_module`, `id_shop`, `id_country`) VALUES '.rtrim($sql, ',');
return Db::getInstance()->execute($sql);
}
else
return true;
}
}