Esempio n. 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;
 }
Esempio n. 2
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;
 }