Exemple #1
0
 public function __construct()
 {
     parent::__construct();
     $this->config = new DpdGroupConfiguration();
     if ($this->config->dpd_country_select == DpdGroupConfiguration::OTHER_COUNTRY) {
         $url = $this->config->production_mode ? $this->config->ws_production_url : $this->config->ws_test_url;
     } else {
         require_once _DPDGROUP_CONTROLLERS_DIR_ . 'Configuration.controller.php';
         $configuration_controller = new DpdGroupConfigurationController();
         $configuration_controller->setAvailableCountries();
         $mode = $this->config->production_mode ? 'ws_uri_prod' : 'ws_uri_test';
         $url = isset($configuration_controller->countries[$this->config->dpd_country_select][$mode]) ? $configuration_controller->countries[$this->config->dpd_country_select][$mode] : '';
     }
     if (!$url) {
         self::$errors[] = $this->l('Wrong WebServices URL');
         return null;
     }
     $this->params = array('wsUserName' => $this->config->ws_username, 'wsPassword' => $this->config->ws_password, 'wsLang' => $this->context->language->iso_code, 'applicationType' => self::APPLICATION_TYPE);
     try {
         ini_set('soap.wsdl_cache_enabled', '0');
         ini_set('soap.wsdl_cache', '0');
         $opts = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false));
         $url .= $this->service_name . '?wsdl';
         $this->client = new SoapClient($url, array('stream_context' => stream_context_create($opts), 'connection_timeout' => (int) $this->config->ws_timeout, 'trace' => true));
         return $this->client;
     } catch (Exception $e) {
         self::$errors[] = $e->getMessage();
     }
     return null;
 }
 public static function init()
 {
     $controller = new DpdGroupConfigurationController();
     if (Tools::isSubmit(self::SETTINGS_SAVE_ACTION)) {
         $controller->validateSettings();
         if (!self::$errors) {
             $controller->createDeleteCarriers();
         }
         if (!self::$errors) {
             $controller->saveSettings();
         } else {
             $controller->module_instance->outputHTML($controller->module_instance->displayError(implode('<br />', self::$errors)));
         }
     }
 }
Exemple #3
0
 /**
  * Check if COD carrier can be visible in checkout pages
  * depending on customer delivery address country and selected currency
  *
  * @param Cart $cart
  * @param DpdGroupConfiguration $configuration
  * @param $id_customer_country
  * @return bool
  */
 private function isCODCarrierAvailable(Cart $cart, DpdGroupConfiguration $configuration, $id_customer_country)
 {
     if ($configuration->dpd_country_select == DpdGroupConfiguration::OTHER_COUNTRY) {
         return true;
     }
     $customer_country_iso_code = Country::getIsoById((int) $id_customer_country);
     if ($configuration->dpd_country_select != $customer_country_iso_code) {
         return false;
     }
     require_once _DPDGROUP_CONTROLLERS_DIR_ . 'Configuration.controller.php';
     $configuration_controller = new DpdGroupConfigurationController();
     $configuration_controller->setAvailableCountries();
     $sender_currency = '';
     if (isset($configuration_controller->countries[$configuration->dpd_country_select]['currency'])) {
         $sender_currency = $configuration_controller->countries[$configuration->dpd_country_select]['currency'];
     }
     if (!$sender_currency) {
         return false;
     }
     $id_cart_currency = (int) $cart->id_currency;
     $cart_currency = Currency::getCurrency((int) $id_cart_currency);
     if ($sender_currency != $cart_currency['iso_code']) {
         return false;
     }
     return true;
 }
Exemple #4
0
 *
 *  @author    JSC INVERTUS www.invertus.lt <*****@*****.**>
 *  @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;