Example #1
0
    require_once dirname(__FILE__) . '/../../init.php';
    $modules = Module::getModulesInstalled();
}
$moduleIsActive = 0;
foreach ($modules as $key => $module) {
    if ($module['name'] == 'shopgate' && !empty($module['active'])) {
        $moduleIsActive = 1;
    }
}
if ($moduleIsActive == 0) {
    throw new ShopgateLibraryException(ShopgateLibraryException::UNKNOWN_ERROR_CODE, 'shopgate module is not installed!');
    exit;
}
// needed for compatiblitiy
function getOrderStateId($order_state_var)
{
    return (int) (defined($order_state_var) ? constant($order_state_var) : (defined('_' . $order_state_var . '_') ? constant('_' . $order_state_var . '_') : Configuration::get($order_state_var)));
}
// select the correct plugin
if (getOrderStateId('PS_COUNTRY_DEFAULT') && ($countryId = getOrderStateId('PS_COUNTRY_DEFAULT')) !== 0 || getOrderStateId('PS_SHOP_COUNTRY_ID') && ($countryId = getOrderStateId('PS_SHOP_COUNTRY_ID')) !== 0) {
    $countryIsoCode = Tools::strtoupper(Db::getInstance()->getValue('SELECT `iso_code` FROM `' . _DB_PREFIX_ . 'country` WHERE `id_country` = ' . (int) $countryId));
} elseif (Configuration::get('PS_LOCALE_COUNTRY')) {
    $countryIsoCode = Configuration::get('PS_LOCALE_COUNTRY');
}
if (in_array(Tools::strtoupper($countryIsoCode), array('US'))) {
    $plugin = new PSShopgatePluginUS();
} else {
    $plugin = new PSShopgatePlugin();
}
$response = $plugin->handleRequest($_POST);