Ejemplo n.º 1
0
 *  @copyright 2015 DPD Polska sp. z o.o.
 *  @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 *  International Registered Trademark & Property of DPD Polska sp. z o.o.
 */
include_once dirname(__FILE__) . '/../../config/config.inc.php';
include_once dirname(__FILE__) . '/../../init.php';
$module_instance = Module::getInstanceByName('dpdgroup');
$filename = 'dpdgroup.ajax';
if (Tools::getValue('token') != sha1(_COOKIE_KEY_ . $module_instance->name) || !$module_instance instanceof DpdGroup) {
    exit;
}
if (Tools::isSubmit('testConnectivity')) {
    require_once _DPDGROUP_CONTROLLERS_DIR_ . 'Configuration.controller.php';
    $configuration_controller = new DpdGroupConfigurationController();
    if ((int) Tools::getValue('other_country')) {
        $error_message = $configuration_controller->testConnection((int) Tools::getValue('production_mode'), Tools::getValue('production_ws_url'), Tools::getValue('test_ws_url'));
    } else {
        $error_message = $configuration_controller->validateCountryConfiguration(Tools::getValue('ws_country'));
    }
    die($error_message ? $error_message : true);
}
if (Tools::isSubmit('calculatePrice')) {
    DpdGroupWS::$parcel_weight_warning_message = false;
    $id_order = (int) Tools::getValue('id_order');
    $shipment = new DpdGroupShipment((int) $id_order);
    $price = $shipment->calculatePriceForOrder((int) Tools::getValue('method_id'), (int) Tools::getValue('id_address'));
    $errors = array();
    if (DpdGroupShipment::$errors) {
        $errors = DpdGroupShipment::$errors;
    }
    $price = $price !== false ? $price : '---';