Esempio n. 1
0
<?php

require dirname(__FILE__) . '/../../config/config.inc.php';
require_once _PS_MODULE_DIR_ . "/tntcarrier/classes/TntWebService.php";
//$erreur = '';
global $smarty, $cookie;
$cookie->id_lang = '2';
try {
    $tntWebService = new TntWebService();
    $follow[] = $tntWebService->followPackage($_GET['code']);
} catch (SoapFault $e) {
    $erreur = $e->faultstring;
    echo $erreur;
} catch (Exception $e) {
    $erreur = "Problem : follow failed";
}
$config['date'] = '%d/%m/%y';
$config['time'] = '%I:%M %p';
//$smarty->assign('erreur', $erreur);
$smarty->assign('config', $config);
$smarty->assign('follow', $follow);
$smarty->display(dirname(__FILE__) . '/tpl/follow.tpl');
 public function getOrderShippingCost($params, $shipping_cost)
 {
     if (!$this->active) {
         return false;
     }
     if (!Configuration::get('TNT_CARRIER_LOGIN') || !Configuration::get('TNT_CARRIER_PASSWORD') || !Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT')) {
         return false;
     }
     if (!Configuration::get('TNT_CARRIER_SHIPPING_ADDRESS1') || !Configuration::get('TNT_CARRIER_SHIPPING_ZIPCODE') || !Configuration::get('TNT_CARRIER_SHIPPING_CITY')) {
         return false;
     }
     if (!extension_loaded('soap')) {
         return false;
     }
     $product = $params->getProducts();
     $weight = 0;
     $add = 0;
     $id_customer = $params->id_customer;
     $id_adress_delivery = $params->id_address_delivery;
     $info = Db::getInstance()->getRow('SELECT postcode, city, company FROM `' . _DB_PREFIX_ . 'address` WHERE `id_address` = "' . (int) $id_adress_delivery . '"');
     foreach ($product as $k => $v) {
         $weight += (double) ($v['weight'] * (int) $v['cart_quantity']);
     }
     $serviceCache = new serviceCache($params->id, $info['postcode'], $info['city'], $info['company'], Configuration::get('TNT_CARRIER_SHIPPING_ZIPCODE'), Configuration::get('TNT_CARRIER_SHIPPING_CITY'));
     $serviceCache->clean();
     if (!$serviceCache->getFaisabilityAtThisTime()) {
         $serviceCache->deletePreviousServices();
         $tntWebService = new TntWebService();
         $typeDestinataire = array();
         $typeDestinataire[] = 'INDIVIDUAL';
         $typeDestinataire[] = 'DROPOFFPOINT';
         if ($info['company'] != '') {
             $typeDestinataire[] = 'ENTERPRISE';
         }
         $faisability = $tntWebService->getFaisability($typeDestinataire, $info['postcode'], $this->putCityInNormeTnt($info['city']), date("Y-m-d", strtotime("now")));
         //"2012-05-02");
         if (!is_array($faisability) && strrpos($faisability, "(zip code / city)") === 0) {
             $serviceCache->errorCodePostal();
         } else {
             if (is_array($faisability)) {
                 $serviceCache->putInCache($faisability);
             }
         }
         if ($faisability == null) {
             return false;
         }
     }
     $service = $serviceCache->getServices();
     if ($service != NULL) {
         foreach ($service as $v) {
             if (Configuration::get('TNT_CARRIER_' . pSQL($v['code']) . '_ID')) {
                 if (Configuration::get('TNT_CARRIER_' . pSQL($v['code']) . '_ID') == $this->id_carrier) {
                     $priceCarrier = Configuration::get('TNT_CARRIER_' . pSQL($v['code']) . '_OVERCOST');
                 }
             } else {
                 if (Configuration::get('TNT_CARRIER_' . substr(pSQL($v['code']), 0, 2) . '_ID')) {
                     if (Configuration::get('TNT_CARRIER_' . substr(pSQL($v['code']), 0, 2) . '_ID') == $this->id_carrier) {
                         $priceCarrier = Configuration::get('TNT_CARRIER_' . substr(pSQL($v['code']), 0, 2) . '_OVERCOST');
                     }
                 }
             }
         }
     }
     $zero = 0;
     $weightLimit = Db::getInstance()->getRow('SELECT additionnal_charges FROM `' . _DB_PREFIX_ . 'tnt_carrier_weight` WHERE `weight_min` < "' . (double) $weight . '" AND (`weight_max` > "' . (double) $weight . '" OR `weight_max` = "' . (double) $zero . '")');
     $currency = Db::getInstance()->getRow('SELECT conversion_rate FROM `' . _DB_PREFIX_ . 'currency` WHERE `id_currency` = "' . (int) $params->id_currency . '"');
     if ($weightLimit != null) {
         $add += (double) $weightLimit['additionnal_charges'];
     }
     if (substr($info['postcode'], 0, 2) == "20") {
         $add += (double) Configuration::get('TNT_CARRIER_CORSE_OVERCOST');
     }
     if (isset($priceCarrier)) {
         return ($priceCarrier + $add) * $currency['conversion_rate'] + $shipping_cost;
     }
     return false;
 }
Esempio n. 3
0
 } else {
     if ($postal == '13000') {
         for ($i = 1; $i <= 16; $i++) {
             if ($i < 10) {
                 $nb = '0' . $i;
             } else {
                 $nb = $i;
             }
             echo '<option value="MARSEILLE ' . $nb . '">MARSEILLE ' . $nb . '</option>';
         }
     } else {
         try {
             if (Tools::getValue('id_shop')) {
                 $tntWebService = new TntWebService(Tools::safeOutput(Tools::getValue('id_shop')));
             } else {
                 $tntWebService = new TntWebService();
             }
             $cities = $tntWebService->getCity($postal);
         } catch (SoapFault $e) {
             $erreur = $e->faultstring;
         } catch (Exception $e) {
             $erreur = "Problem : follow failed";
         }
         if (!isset($erreur)) {
             if (isset($cities->City) && is_array($cities->City)) {
                 foreach ($cities->City as $v) {
                     echo '<option value="' . $v->name . '">' . $v->name . '</option>';
                 }
             } else {
                 if (isset($cities->City)) {
                     echo '<option value="' . $cities->City->name . '">' . $cities->City->name . '</option>';
Esempio n. 4
0
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2014 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
require dirname(__FILE__) . '/../../config/config.inc.php';
require_once _PS_MODULE_DIR_ . "/tntcarrier/classes/TntWebService.php";
global $smarty, $cookie;
$cookie->id_lang = (int) Language::getIdByIso('fr');
try {
    $tntWebService = new TntWebService();
    $follow[] = $tntWebService->followPackage(Tools::getValue('code'));
} catch (SoapFault $e) {
    $error = $e->faultstring;
    echo $error;
} catch (Exception $e) {
    $error = "Problem : follow failed";
}
$config['date'] = '%d/%m/%y';
$config['time'] = '%I:%M %p';
$smarty->assign('config', $config);
$smarty->assign('follow', $follow);
$smarty->display(dirname(__FILE__) . '/tpl/follow.tpl');