function __construct() { parent::__construct(); $this->_dhl_post_url = $this->getServerURL(); if (isset($_POST)) { $this->prepareLabelInfo(); $this->_dhl_label_packages = Tools::getValue('pack'); $this->_response['errors'] = $this->validateRequiredInfos(); $this->_response['success'] = array(); } }
public function getDHLRates($id_zone, $is_cart, $cart, $product_weight, $dest_zip, $dest_state, $dest_country, $currency, $product, $id_product_attribute, $qty, $dest_city) { $rates = array(); if (file_exists(dirname(__FILE__) . '/../../dhl/classes/RateAvailableServices.php')) { include_once dirname(__FILE__) . '/../../dhl/dhl.php'; include_once dirname(__FILE__) . '/../../dhl/classes/RateAvailableServices.php'; $dhl = new DHL(); if ($dhl->active) { // Get handling cost (once) $handling = Configuration::get('PS_SHIPPING_HANDLING'); $carriers = $dhl->getCarriers($id_zone, $cart, $is_cart, $product); $dhl_rate = new DHLRate(); foreach ($carriers as $carrier) { $amount = $dhl_rate->getRate($carrier['id_carrier'], $carrier['id_zone'], $is_cart != '' ? $cart->getTotalWeight() : max($product_weight, 0.001), $dest_zip, "", $dest_country, $dest_city, $is_cart != '' ? 0 : $product->getPrice(true, $id_product_attribute, 6, NULL, false, true, $qty), $is_cart != '' ? 0 : $product->id, $is_cart != '' ? 0 : $id_product_attribute, $qty); // Add product spercific cost + handling fee if ($amount > 0) { $amount += $this->getExtraShippingCost($carrier, $handling, $is_cart != '' ? $cart->getProducts() : array(), $product, $qty); } // Apply shipping tax if needed if (!Tax::excludeTaxeOption()) { $carrierTax = Tax::getCarrierTaxRate($carrier['id_carrier']); } if (isset($carrierTax) && $amount !== false) { $amount *= 1 + $carrierTax / 100; } $amount = $amount === false ? -1 : Tools::convertPrice($amount, $currency); if ($amount > 0) { $rates[$carrier['name']] = array(Tools::displayPrice($amount, $currency, false), $carrier['id_carrier']); } elseif ($amount !== false && $amount == 0) { $rates[$carrier['name']] = array($dhl->l('Free!'), $carrier['id_carrier']); } } } } return $rates; }
<?php include dirname(__FILE__) . '/../../config/config.inc.php'; include dirname(__FILE__) . '/../../init.php'; if (substr(_PS_VERSION_, 0, 3) == '1.5' && Tools::getValue('id_employee')) { $context = Context::getContext(); $context->cookie->id_employee = Tools::getValue('id_employee'); $context->employee = new Employee(Tools::getValue('id_employee')); } include_once dirname(__FILE__) . '/dhl.php'; include_once dirname(__FILE__) . '/classes/LabelPrinting.php'; $dhl = new DHL(); $LabelPrinting = new LabelPrinting(); if (Tools::getValue('dhl_random') != $dhl->_dhl_random) { exit; } if (Tools::isSubmit('shippingLabel') and Tools::isSubmit('id_order')) { $label = $LabelPrinting->getShippingLabel(Tools::getValue('id_order')); $ajax = Tools::getValue('ajax'); $tryagain = $ajax == 1 ? $dhl->l('Please change incorrect settings and try again.', 'display_label') : $dhl->l('Please close this tab and change incorrect settings at previous page.', 'display_label'); $html = ''; $tempLabels = array(); if (isset($label['errors']) && is_array($label['errors']) && count($label['errors'])) { $html .= '<p style="color: red;margin: 20px 0 0 0;border: 1px solid;padding: 5px;"><span style="font-weight:bold;">' . $dhl->l('There is ', 'display_label') . count($label['errors']) . $dhl->l(' error(s)', 'display_label') . '</span><br /><br />'; foreach ($label['errors'] as $error) { $html .= ($error['HelpContext'] ? '[#' . $error['HelpContext'] . '] ' : '- ') . $error['Description'] . '<br />'; } $html .= '<br />' . $tryagain . '</p>'; } elseif ($label[0] == 0) { $html .= '<p style="color: red;margin: 20px 0 0 0;border: 1px solid;padding: 5px;"><span style="font-weight:bold;">' . $dhl->l('Error', 'display_label') . ':</span> ' . $label[1] . '<br /><br />' . $tryagain . '</p>'; } elseif ($label[0] == 1) {
<?php include_once dirname(__FILE__) . '/../../config/config.inc.php'; include_once dirname(__FILE__) . '/../../init.php'; include_once dirname(__FILE__) . '/dhl.php'; $dhl = new DHL(); if (Tools::getValue('dhl_random') != $dhl->_dhl_random) { exit; } $ps_version = floatval(substr(_PS_VERSION_, 0, 3)); if (Tools::isSubmit('save') and Tools::getValue('id_order') > 0) { $id_order = Tools::getValue('id_order'); foreach ($_POST as $field => $value) { if ($field == 'pack') { foreach ($value as $box => $info) { /* FIX PACKAGE DELETING ACTION */ if (!isset($info['type']) || !isset($info['h']) && !isset($info['w']) && !isset($info['d'])) { unset($_POST['pack'][$box]); } } } } $data = $_POST; Configuration::updateValue('DHL_LABEL_FORMAT', $data['label_format']); //label format, global setting unset($data['save']); foreach ($data as &$item) { $item = is_string($item) ? htmlspecialchars(stripslashes($item)) : $item; } $data_ser = serialize($data); $label_info = Db::getInstance()->executeS('
$obj = new StdClass(); foreach ($array as $key => $val) { $obj->{$key} = $val; } } else { $obj = $array; } return $obj; } include dirname(__FILE__) . '/../../config/config.inc.php'; include dirname(__FILE__) . '/../../init.php'; include dirname(__FILE__) . '/classes/RateAvailableServices.php'; include_once dirname(__FILE__) . '/JSON.php'; include_once dirname(__FILE__) . '/dhl.php'; $exceptions = false; $dhl = new DHL(); $return = array(); if (isset($_POST['action']) && $_POST['action'] == 'add') { $dhl->_dhl_boxes[] = array((double) $_POST['width'], (double) $_POST['height'], (double) $_POST['depth'], (double) $_POST['weight'] <= 0 ? 150 : (double) $_POST['weight']); // Sort needed // foreach ($dhl->_dhl_boxes as $box) { $tot = round($box[0] * $box[1] * $box[2]); while (isset($arr_tmp[$tot])) { $tot++; } $arr_tmp[$tot] = $box; } ksort($arr_tmp); foreach ($arr_tmp as $box) { $sorted[] = $box; }
<?php include_once dirname(__FILE__) . '/../../config/config.inc.php'; include_once dirname(__FILE__) . '/../../init.php'; include_once dirname(__FILE__) . '/classes/RateAvailableServices.php'; include_once dirname(__FILE__) . '/JSON.php'; $log = false; $sti = microtime(); $ps_version = floatval(substr(_PS_VERSION_, 0, 3)); $dhl = new DHL(); $is_cart = Tools::getValue('dhl_is_cart'); $qty = Tools::getValue('qty'); $dhl->updateCartWithNewCarrier(); $dhl->saveLog('dhl_log1.txt', "Starting {$sti} " . print_r($_POST, true), $log); // Get Address and zone $address = $dhl->getPreviewAddress($log); if (isset($_POST['id_product'])) { $product = new Product($_POST['id_product']); } $id_product_attribute = Tools::getValue('id_product_attribute', '0'); $product_weight = $product->weight; // Add combination weight impact if ($id_product_attribute != 0) { $product_weight += Db::getInstance()->getValue('SELECT `weight` FROM `' . _DB_PREFIX_ . 'product_attribute` WHERE `id_product_attribute` = ' . (int) $id_product_attribute); } $is_downloadable = ProductDownload::getIdFromIdProduct($_POST['id_product']); if ($is_downloadable) { $json = array("dhl_rate_tpl" => $dhl->hookAjaxPreview($rates, $address['dest_zip'], $address['dest_state'], $address['dest_country'], true, $is_cart)); } else { $context = $dhl->getContext(); $currency = new Currency($context->currency->id);