function getContent()
    {
        $configKeys = array('EBAY_SECURITY_TOKEN', 'PS_LANG_DEFAULT');
        // Load prestashop ebay's configuration
        $configs = Configuration::getMultiple($configKeys);
        $profile_configs = $this->ebay_profile->getMultiple(array('EBAY_DELIVERY_TIME', 'EBAY_ZONE_NATIONAL', 'EBAY_ZONE_INTERNATIONAL'));
        // Check if the module is configured
        if (!$this->ebay_profile->getConfiguration('EBAY_PAYPAL_EMAIL')) {
            $template_vars = array('error_form_shipping' => 'true');
            return $this->display('error_paypal_email.tpl', $template_vars);
        }
        $nb_shipping_zones_excluded = DB::getInstance()->getValue('SELECT COUNT(*) 
			FROM ' . _DB_PREFIX_ . 'ebay_shipping_zone_excluded
			WHERE `id_ebay_profile` = ' . (int) $this->ebay_profile->id);
        if (!$nb_shipping_zones_excluded) {
            EbayShippingZoneExcluded::loadEbayExcludedLocations($this->ebay_profile->id);
        }
        $module_filters = version_compare(_PS_VERSION_, '1.4.5', '>=') ? Carrier::CARRIERS_MODULE : 2;
        //INITIALIZE CACHE
        $psCarrierModule = $this->ebay_profile->getCarriers($configs['PS_LANG_DEFAULT'], false, false, false, null, $module_filters);
        $url_vars = array('id_tab' => '3', 'section' => 'shipping');
        if (version_compare(_PS_VERSION_, '1.5', '>')) {
            $url_vars['controller'] = Tools::getValue('controller');
        } else {
            $url_vars['tab'] = Tools::getValue('tab');
        }
        $zones = Zone::getZones(true);
        foreach ($zones as &$zone) {
            $zone['carriers'] = Carrier::getCarriers($this->context->language->id, false, false, $zone['id_zone']);
        }
        $template_vars = array('eBayCarrier' => EbayShippingService::getCarriers($this->ebay_profile->ebay_site_id), 'psCarrier' => $this->ebay_profile->getCarriers($configs['PS_LANG_DEFAULT']), 'psCarrierModule' => $psCarrierModule, 'existingNationalCarrier' => EbayShipping::getNationalShippings($this->ebay_profile->id), 'existingInternationalCarrier' => EbayShippingInternationalZone::getExistingInternationalCarrier($this->ebay_profile->id), 'deliveryTime' => $profile_configs['EBAY_DELIVERY_TIME'], 'prestashopZone' => Zone::getZones(), 'excludeShippingLocation' => EbayShippingZoneExcluded::cacheEbayExcludedLocation($this->ebay_profile->id), 'internationalShippingLocations' => EbayShippingLocation::getInternationalShippingLocations(), 'deliveryTimeOptions' => EbayDeliveryTimeOptions::getDeliveryTimeOptions(), 'formUrl' => $this->_getUrl($url_vars), 'ebayZoneNational' => isset($profile_configs['EBAY_ZONE_NATIONAL']) ? $profile_configs['EBAY_ZONE_NATIONAL'] : false, 'ebayZoneInternational' => isset($profile_configs['EBAY_ZONE_INTERNATIONAL']) ? $profile_configs['EBAY_ZONE_INTERNATIONAL'] : false, 'ebay_token' => $configs['EBAY_SECURITY_TOKEN'], 'id_ebay_profile' => $this->ebay_profile->id, 'newPrestashopZone' => $zones);
        return $this->display('shipping.tpl', $template_vars);
    }
 public function __construct()
 {
     $this->name = 'tntcarrier';
     $this->tab = 'shipping_logistics';
     $this->version = '1.8';
     $this->author = 'PrestaShop';
     $this->limited_countries = array('fr');
     $this->module_key = 'd4dcfde9937b67002235598ac35cbdf8';
     parent::__construct();
     $this->displayName = $this->l('TNT Express');
     $this->description = $this->l('Offer your customers, different delivery methods with TNT');
     if (self::isInstalled($this->name)) {
         global $cookie;
         $warning = array();
         $this->loadingVar();
         $carriers = Carrier::getCarriers($cookie->id_lang, true, false, false, null, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
         foreach ($this->_fieldsList as $keyConfiguration => $name) {
             if (!Configuration::get($keyConfiguration) && !empty($name)) {
                 $warning[] = '\'' . $name . '\' ';
             }
         }
         // Saving id carrier list
         $id_carrier_list = array();
         foreach ($carriers as $carrier) {
             $id_carrier_list[] .= $carrier['id_carrier'];
         }
         if (count($warning) > 1) {
             $this->warning .= implode(' , ', $warning) . $this->l('must be configured to use this module correctly.') . ' ';
         }
         if (count($warning) == 1) {
             $this->warning .= implode(' , ', $warning) . $this->l('has to be configured to use this module correctly.') . ' ';
         }
     }
 }
 public function initContent()
 {
     $array_carrier = array();
     $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     foreach ($carriers as $key => $carrier) {
         if ($carrier['is_free']) {
             unset($carriers[$key]);
         } else {
             $array_carrier[] = $carrier['id_carrier'];
         }
     }
     $id_carrier = (int) Tools::getValue('id_carrier');
     if (count($carriers) && isset($array_carrier[0])) {
         if (!$id_carrier) {
             $id_carrier = (int) $array_carrier[0];
         }
         $carrierSelected = new Carrier((int) $id_carrier);
     } else {
         $carrierSelected = new Carrier((int) $id_carrier);
     }
     $currency = $this->context->currency;
     $rangeObj = $carrierSelected->getRangeObject();
     $rangeTable = $carrierSelected->getRangeTable();
     $suffix = $carrierSelected->getRangeSuffix();
     $rangeIdentifier = 'id_' . $rangeTable;
     $ranges = $rangeObj->getRanges($id_carrier);
     $delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier);
     $deliveryArray = array();
     foreach ($delivery as $deliv) {
         $deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
     }
     $this->context->smarty->assign(array('zones' => $carrierSelected->getZones(), 'carriers' => $carriers, 'ranges' => $ranges, 'currency' => $currency, 'deliveryArray' => $deliveryArray, 'carrierSelected' => $carrierSelected, 'id_carrier' => $id_carrier, 'suffix' => $suffix, 'rangeIdentifier' => $rangeIdentifier, 'action_fees' => self::$currentIndex . '&token=' . $this->token));
     parent::initContent();
 }
 protected function getOptionFields()
 {
     $forms = array();
     $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
     $carriers = Carrier::getCarriers($this->context->language->id, true);
     $modules = Module::getModulesOnDisk(true);
     $forms = array('payment' => array('title' => $this->l('Average bank fees per payment method'), 'id' => 'payment'), 'carriers' => array('title' => $this->l('Average shipping fees per shipping method'), 'id' => 'carriers'), 'other' => array('title' => $this->l('Other settings'), 'id' => 'other'), 'expenses' => array('title' => $this->l('Other expenses (monthly)'), 'id' => 'expenses'));
     foreach ($forms as &$form) {
         $form['icon'] = 'tab-preferences';
         $form['fields'] = array();
         $form['submit'] = array('title' => $this->l('Save'));
     }
     foreach ($modules as $module) {
         if ($module->tab == 'payments_gateways' && $module->id) {
             $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed in %1$s with %2$s.'), $currency->iso_code, $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
             $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed in %1$s with %2$s. It will be applied on the total paid with taxes.'), $currency->iso_code, $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
             if (Currency::isMultiCurrencyActivated()) {
                 $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed with a foreign currency with %s.'), $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
                 $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed with a foreign currency with %s. It will be applied on the total paid with taxes.'), $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
             }
         }
     }
     foreach ($carriers as $carrier) {
         $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('%% of what you charged the customer for domestic delivery with %s.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
         $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP_OVERSEAS'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('%% of what you charged the customer for overseas delivery with %s.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
     }
     $forms['other']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array('title' => $this->l('Average gross margin (Selling price / Buying price)'), 'desc' => $this->l('Only used if you do not specify your buying price for each product.'), 'validation' => 'isPercentage', 'cast' => 'intval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
     $forms['other']['fields']['CONF_ORDER_FIXED'] = array('title' => $this->l('Other fee per order'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
     $expense_types = array('hosting' => $this->l('Hosting'), 'tools' => $this->l('Tools (E-mailing, etc.)'), 'acounting' => $this->l('Accounting'), 'development' => $this->l('Development'), 'marketing' => $this->l('Marketing (Adwords, etc.)'), 'others' => $this->l('Others'));
     foreach ($expense_types as $expense_type => $expense_label) {
         $forms['expenses']['fields']['CONF_MONTHLY_' . strtoupper($expense_type)] = array('title' => $expense_label, 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
     }
     return $forms;
 }
 protected function getOptionFields()
 {
     $forms = array();
     $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
     $carriers = Carrier::getCarriers($this->context->language->id, true);
     $modules = Module::getModulesOnDisk(true);
     $forms = array('payment' => array('title' => $this->l('Average bank fees per payment method'), 'id' => 'payment'), 'carriers' => array('title' => $this->l('Average shipping fees per shipping method'), 'id' => 'carriers'), 'other' => array('title' => $this->l('Other settings'), 'id' => 'other'));
     foreach ($forms as &$form) {
         $form['icon'] = 'tab-preferences';
         $form['fields'] = array();
         $form['submit'] = array('title' => $this->l('Save'));
     }
     foreach ($modules as $module) {
         if (isset($module->tab) && $module->tab == 'payments_gateways' && $module->id) {
             $moduleClass = Module::getInstanceByName($module->name);
             if (!$moduleClass->isEnabledForShopContext()) {
                 continue;
             }
             $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed in %1$s with %2$s.'), $currency->iso_code, $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
             $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed in %1$s with %2$s. It will be applied on the total paid with taxes.'), $currency->iso_code, $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
             if (Currency::isMultiCurrencyActivated()) {
                 $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_FIXED_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a fixed fee for each order placed with a foreign currency with %s.'), $module->displayName), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
                 $forms['payment']['fields']['CONF_' . strtoupper($module->name) . '_VAR_FOREIGN'] = array('title' => $module->displayName, 'desc' => sprintf($this->l('Choose a variable fee for each order placed with a foreign currency with %s. It will be applied on the total paid with taxes.'), $module->displayName), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
             }
         }
     }
     foreach ($carriers as $carrier) {
         $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('For the carrier named %s, indicate the domestic delivery costs  in percentage of the price charged to customers.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
         $forms['carriers']['fields']['CONF_' . strtoupper($carrier['id_reference']) . '_SHIP_OVERSEAS'] = array('title' => $carrier['name'], 'desc' => sprintf($this->l('For the carrier named %s, indicate the overseas delivery costs in percentage of the price charged to customers.'), $carrier['name']), 'validation' => 'isPercentage', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
     }
     $forms['carriers']['description'] = $this->l('Method: Indicate the percentage of your carrier margin. For example, if you charge $10 of shipping fees to your customer for each shipment, but you really pay $4 to this carrier, then you should indicate "40" in the percentage field.');
     $forms['other']['fields']['CONF_AVERAGE_PRODUCT_MARGIN'] = array('title' => $this->l('Average gross margin'), 'desc' => $this->l('You should calculate this percentage as follows: ((total sales revenue) - (cost of goods sold)) / (total sales revenue) * 100. This value is only used to calculate the Dashboard approximate gross margin, if you do not specify the wholesale price for each product.'), 'validation' => 'isPercentage', 'cast' => 'intval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => '%');
     $forms['other']['fields']['CONF_ORDER_FIXED'] = array('title' => $this->l('Other fees per order'), 'desc' => $this->l('You should calculate this value by making the sum of all of your additional costs per order.'), 'validation' => 'isPrice', 'cast' => 'floatval', 'type' => 'text', 'defaultValue' => '0', 'suffix' => $currency->iso_code);
     return $forms;
 }
Beispiel #6
0
    private function _displayForm()
    {
        $this->_html .= '
        <form method="post" action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '">
			<fieldset>
				<legend><img src="' . $this->_path . 'logo.png" width="16" height="16"/>' . $this->l('Settings') . '</legend> 
				
                <label>' . $this->l('Carrier') . '</label>
				<div class="margin-form">
                    <select name="STORE_DELIVERY_CARRIER">';
        foreach (Carrier::getCarriers($this->context->language->id) as $carrier) {
            $this->_html .= '<option value="' . $carrier['id_carrier'] . '"' . ($carrier['id_carrier'] == Configuration::get('STORE_DELIVERY_CARRIER') ? ' selected="selected"' : '') . '>' . $carrier['name'] . '</option>';
        }
        $this->_html .= '</select>
                    <p class="clear">' . $this->l('Choose here a carrier used for the delivery in store') . '</p>
                </div>
				<div class="clear"></div>
                
                <label>' . $this->l('Send email to store to prevent new order') . '</label>
				<div class="margin-form">
                    <input type="radio" name="STORE_DELIVERY_SEND_MAIL" id="sendmail_on" value="1" ' . (Configuration::get('STORE_DELIVERY_SEND_MAIL') == '1' ? 'checked="checked" ' : '') . '/>
					<label class="t" for="sendmail_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="STORE_DELIVERY_SEND_MAIL" id="sendmail_off" value="0" ' . (Configuration::get('STORE_DELIVERY_SEND_MAIL') == '0' ? 'checked="checked" ' : '') . '/>
					<label class="t" for="sendmail_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p class="clear">' . $this->l('You must enter email address in each store admin') . '</p>
				</div>
				<div class="clear"></div>
                
                <label>' . $this->l('Display Google Map') . '</label>
				<div class="margin-form">
                    <input type="radio" name="STORE_DELIVERY_DISPLAY_MAP" id="map_on" value="1" ' . (Configuration::get('STORE_DELIVERY_DISPLAY_MAP') == '1' ? 'checked="checked" ' : '') . '/>
					<label class="t" for="map_on"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" /></label>
					<input type="radio" name="STORE_DELIVERY_DISPLAY_MAP" id="map_off" value="0" ' . (Configuration::get('STORE_DELIVERY_DISPLAY_MAP') == '0' ? 'checked="checked" ' : '') . '/>
					<label class="t" for="map_off"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" /></label>
					<p class="clear">' . $this->l("You can display a map of stores. Don't forgot to change default latitude/longitude in Store Contact page (under Preference/Store Contact admin page)") . '</p>
				</div>
				<div class="clear"></div>
                
                <label>' . $this->l('Height of Google map') . '</label>
				<div class="margin-form">
					<input type="text" name="STORE_DELIVERY_HEIGHT_MAP" value="' . Configuration::get('STORE_DELIVERY_HEIGHT_MAP') . '"/>
                        <p class="clear">' . $this->l('Height of map in px (for exemple enter "300px")') . '</p>
                </div>
				<div class="clear"></div>
                
                <label>' . $this->l('Width of Google map') . '</label>
				<div class="margin-form">
					<input type="text" name="STORE_DELIVERY_WIDTH_MAP" value="' . Configuration::get('STORE_DELIVERY_WIDTH_MAP') . '"/>
                    <p class="clear">' . $this->l('Width of map in px or % (for exemple enter "725px" or "100%"...)') . '</p>
                </div>
				<div class="clear"></div>
                
				<div class="margin-form clear pspace">
                    <input type="submit" name="submitUpdate" value="' . $this->l('Update') . '" class="button" />
                </div>
			</fieldset>
		</form>';
        return $this->_html;
    }
Beispiel #7
0
 /**
  * Initializes the class.
  *
  * @param string $code The provider code.
  * 
  * @return void
  */
 public function __construct($code)
 {
     $providers = array_merge(self::$providers, Carrier::getCarriers());
     if (!array_key_exists($code, $providers)) {
         return false;
     }
     $this->code = $code;
     $this->name = $providers[$code];
 }
Beispiel #8
0
 function displayOrderStep($params)
 {
     global $smarty, $cart, $cookie, $defaultCountry;
     if ($isVirtualCart = $cart->isVirtualCart()) {
         $cart->id_carrier = 0;
         $cart->update();
     }
     $smarty->assign('virtual_cart', $isVirtualCart);
     $address = new Address(intval($cart->id_address_delivery));
     $id_zone = Address::getZoneById($address->id);
     $result = Carrier::getCarriers(intval($cookie->id_lang), true, false, intval($id_zone));
     $resultsArray = array();
     foreach ($result as $k => $row) {
         $carrier = new Carrier(intval($row['id_carrier']));
         if (Configuration::get('PS_SHIPPING_METHOD') and !$carrier->getMaxDeliveryPriceByWeight($id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !$carrier->getMaxDeliveryPriceByPrice($id_zone)) {
             unset($result[$k]);
             continue;
         }
         if ($row['range_behavior']) {
             // Get id zone
             if (isset($cart->id_address_delivery) and $cart->id_address_delivery) {
                 $id_zone = Address::getZoneById(intval($cart->id_address_delivery));
             } else {
                 $id_zone = intval($defaultCountry->id_zone);
             }
             if (Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $cart->getTotalWeight(), $id_zone) or !Configuration::get('PS_SHIPPING_METHOD') and !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $cart->getOrderTotalLC(true, 4), $id_zone)) {
                 unset($result[$k]);
                 continue;
             }
         }
         $row['name'] = strval($row['name']) != '0' ? $row['name'] : Configuration::get('PS_SHOP_NAME');
         $row['price'] = $cart->getOrderShippingCostLC(intval($row['id_carrier']));
         $row['price_tax_exc'] = $cart->getOrderShippingCostLC(intval($row['id_carrier']), false);
         $row['img'] = file_exists(_PS_SHIP_IMG_DIR_ . intval($row['id_carrier']) . '.jpg') ? _THEME_SHIP_DIR_ . intval($row['id_carrier']) . '.jpg' : '';
         $row['extra'] = Module::hookExec('extraCarrierDetails', array("row" => $row, "carrier" => $carrier));
         $resultsArray[] = $row;
     }
     // Wrapping fees
     $wrapping_fees = floatval(Configuration::get('PS_GIFT_WRAPPING_PRICE'));
     $wrapping_fees_tax = new Tax(intval(Configuration::get('PS_GIFT_WRAPPING_TAX')));
     $wrapping_fees_tax_exc = $wrapping_fees / (1 + floatval($wrapping_fees_tax->rate) / 100);
     if (Validate::isUnsignedInt($cart->id_carrier)) {
         $carrier = new Carrier(intval($cart->id_carrier));
         if ($carrier->active and !$carrier->deleted) {
             $checked = intval($cart->id_carrier);
         }
     }
     if (!isset($checked)) {
         $checked = intval(Configuration::get('PS_CARRIER_DEFAULT'));
     }
     $smarty->assign(array('checkedTOS' => intval($cookie->checkedTOS), 'recyclablePackAllowed' => intval(Configuration::get('PS_RECYCLABLE_PACK')), 'giftAllowed' => intval(Configuration::get('PS_GIFT_WRAPPING')), 'conditions' => intval(Configuration::get('PS_CONDITIONS')), 'recyclable' => intval($cart->recyclable), 'gift_wrapping_price' => floatval(Configuration::get('PS_GIFT_WRAPPING_PRICE')), 'carriers' => $resultsArray, 'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address)), 'checked' => intval($checked), 'back' => strval(Tools::getValue('back')), 'total_wrapping' => number_format($wrapping_fees, 2, '.', ''), 'total_wrapping_tax_exc' => number_format($wrapping_fees_tax_exc, 2, '.', '')));
     Tools::safePostVars();
     $css_files = array(__PS_BASE_URI__ . 'css/thickbox.css' => 'all');
     $js_files = array(__PS_BASE_URI__ . 'js/jquery/thickbox-modified.js');
     include_once dirname(__FILE__) . '/../../header.php';
     echo $this->display(__FILE__, 'ordercarrier.tpl');
 }
 public static function getCarrierByName($name)
 {
     global $cookie;
     $carriers = Carrier::getCarriers($cookie->id_lang, true, false, false, NULL, ALL_CARRIERS);
     foreach ($carriers as $carrier) {
         if (!$carrier['deleted'] and $carrier['external_module_name'] == $name) {
             return new Carrier($carrier['id_carrier']);
         }
     }
 }
Beispiel #10
0
 public function getCarriersList()
 {
     $carriers = Carrier::getCarriers($this->mCookie->id_lang);
     $binded = unserialize(Configuration::get(self::KONFIG_PREFIX . self::KONFIG_POWIAZANIA_KURIEROW));
     $list = array();
     foreach ($carriers as $key => $c) {
         $list[] = new BindedCarrier($c['id_carrier'], $c['name'], is_array($binded) && isset($binded[$c['id_carrier']]) ? $binded[$c['id_carrier']] : "false");
     }
     return $list;
 }
 public function renderForm()
 {
     $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     foreach ($carriers as $key => $carrier) {
         if ($carrier['is_free']) {
             unset($carriers[$key]);
         }
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Weight ranges'), 'icon' => 'icon-suitcase'), 'input' => array(array('type' => 'select', 'label' => $this->l('Carrier'), 'name' => 'id_carrier', 'required' => false, 'hint' => $this->l('You can apply this range to a different carrier by selecting its name.'), 'options' => array('query' => $carriers, 'id' => 'id_carrier', 'name' => 'name'), 'empty_message' => '<p class="alert alert-block">' . $this->l('There is no carrier available for this weight range.') . '</p>'), array('type' => 'text', 'label' => $this->l('From'), 'name' => 'delimiter1', 'required' => true, 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'hint' => $this->l('Start range (included).')), array('type' => 'text', 'label' => $this->l('To'), 'name' => 'delimiter2', 'required' => true, 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'hint' => $this->l('End range (excluded).'))), 'submit' => array('title' => $this->l('   Save   '), 'class' => 'btn btn-default'));
     return parent::renderForm();
 }
 public function renderForm()
 {
     $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     foreach ($carriers as $key => $carrier) {
         if ($carrier['is_free']) {
             unset($carriers[$key]);
         }
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Weight ranges'), 'image' => '../img/t/AdminRangeWeight.gif'), 'input' => array(array('type' => 'select', 'label' => $this->l('Carrier:'), 'name' => 'id_carrier', 'required' => false, 'desc' => $this->l('You can apply this range to a different carrier by selecting its name.'), 'options' => array('query' => $carriers, 'id' => 'id_carrier', 'name' => 'name'), 'empty_message' => '<div style="margin:5px 0 10px 0">' . $this->l('There is no carrier available for this weight range.') . '</div>'), array('type' => 'text', 'label' => $this->l('From:'), 'name' => 'delimiter1', 'size' => 5, 'required' => true, 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'desc' => $this->l('Range start (included)')), array('type' => 'text', 'label' => $this->l('To:'), 'name' => 'delimiter2', 'size' => 5, 'required' => true, 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'desc' => $this->l('Range end (excluded)'))), 'submit' => array('title' => $this->l('   Save   '), 'class' => 'button'));
     return parent::renderForm();
 }
 public function renderForm()
 {
     $currency = $this->context->currency;
     $carriers = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     foreach ($carriers as $key => $carrier) {
         if ($carrier['is_free']) {
             unset($carriers[$key]);
         }
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Price ranges'), 'icon' => 'icon-money'), 'input' => array(array('type' => 'select', 'label' => $this->l('Carrier'), 'name' => 'id_carrier', 'required' => false, 'hint' => $this->l('You can apply this range to a different carrier by selecting its name.'), 'options' => array('query' => $carriers, 'id' => 'id_carrier', 'name' => 'name'), 'empty_message' => '<p class="alert alert-block">' . $this->l('There is no carrier available for this price range.') . '</p>'), array('type' => 'text', 'label' => $this->l('From'), 'name' => 'delimiter1', 'required' => true, 'suffix' => $currency->getSign('right') . ' ' . $this->l('(Tax Incl.)'), 'hint' => $this->l('Start range (included).'), 'string_format' => '%.2f'), array('type' => 'text', 'label' => $this->l('To'), 'name' => 'delimiter2', 'required' => true, 'suffix' => $currency->getSign('right') . ' ' . $this->l('(Tax Incl.)'), 'hint' => $this->l('End range (excluded).'), 'string_format' => '%.2f')), 'submit' => array('title' => $this->trans('Save', array(), 'Admin.Actions'), 'class' => 'btn btn-default'));
     return parent::renderForm();
 }
 public function renderForm()
 {
     $currency = $this->context->currency;
     $carriers = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     foreach ($carriers as $key => $carrier) {
         if ($carrier['is_free']) {
             unset($carriers[$key]);
         }
     }
     $this->fields_form = array('legend' => array('title' => $this->l('Price ranges'), 'image' => '../img/t/AdminRangePrice.gif'), 'input' => array(array('type' => 'select', 'label' => $this->l('Carrier:'), 'name' => 'id_carrier', 'required' => false, 'desc' => $this->l('You can apply this range to a different carrier by selecting its name.'), 'options' => array('query' => $carriers, 'id' => 'id_carrier', 'name' => 'name'), 'empty_message' => '<div style="margin:5px 0 10px 0">' . $this->l('There is no carrier available for this price range.') . '</div>'), array('type' => 'text', 'label' => $this->l('From:'), 'name' => 'delimiter1', 'size' => 5, 'required' => true, 'suffix' => $currency->getSign('right') . ' ' . $this->l('(Tax Incl.)'), 'desc' => $this->l('Start range (included)'), 'string_format' => '%.2f'), array('type' => 'text', 'label' => $this->l('To:'), 'name' => 'delimiter2', 'size' => 5, 'required' => true, 'suffix' => $currency->getSign('right') . ' ' . $this->l('(Tax Incl.)'), 'desc' => $this->l('End range (excluded)'), 'string_format' => '%.2f')), 'submit' => array('title' => $this->l('   Save   '), 'class' => 'button'));
     return parent::renderForm();
 }
 public function __construct()
 {
     $this->table = 'powatag_configuration';
     $this->lang = false;
     $this->_select = null;
     //If needed you can add informations to select issued from other databases
     $this->_join = null;
     //Join the databases here
     parent::__construct();
     $this->bootstrap = true;
     $this->fields_options = array('api_settings' => array('title' => $this->l('API Settings'), 'image' => '../img/admin/prefs.gif', 'fields' => array('POWATAG_API_KEY' => array('title' => $this->l('API Key'), 'validation' => 'isString', 'type' => 'text', 'size' => '80', 'visibility' => Shop::CONTEXT_SHOP, 'required' => true), 'POWATAG_HMAC_KEY' => array('title' => $this->l('HMAC Key'), 'validation' => 'isString', 'type' => 'text', 'visibility' => Shop::CONTEXT_SHOP, 'size' => 80, 'required' => true), 'POWATAG_GENERATOR_URL' => array('title' => $this->l('Powatag Endpoint URL'), 'validation' => 'isString', 'type' => 'text', 'size' => 80), 'POWATAG_JS_URL' => array('title' => $this->l('Head JavaScript URL'), 'validation' => 'isString', 'type' => 'text', 'size' => 80), 'POWATAG_CSS_URL' => array('title' => $this->l('Head CSS URL'), 'validation' => 'isString', 'type' => 'text', 'size' => 80), 'POWATAG_LEGACY_ERRORS' => array('title' => $this->l('Legacy error codes enabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP)), 'submit' => array('title' => $this->l('Save'))), 'other_settings' => array('title' => $this->l('Other Settings'), 'image' => '../img/admin/tab-tools.gif', 'fields' => array('POWATAG_SHIPPING' => array('title' => $this->l('Shipping Method'), 'validation' => 'isInt', 'type' => 'select', 'identifier' => 'id_carrier', 'desc' => $this->l('This will be used to calculate shipping costs'), 'list' => Carrier::getCarriers($this->context->language->id, false, false, false, null, Carrier::ALL_CARRIERS), 'visibility' => Shop::CONTEXT_SHOP, 'required' => true), 'POWATAG_SUCCESS_MSG' => array('title' => $this->l('Sucess message'), 'validation' => 'isString', 'type' => 'textLang', 'size' => '80', 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_IMG_TYPE' => array('title' => $this->l('Image type to send'), 'validation' => 'isInt', 'type' => 'select', 'identifier' => 'id_image_type', 'list' => ImageType::getImagesTypes(), 'visibility' => Shop::CONTEXT_SHOP, 'required' => true)), 'submit' => array('title' => $this->l('Save'))), 'product_settings' => array('title' => $this->l('Product Settings'), 'image' => $this->module->getPathUri() . 'img/qr_code.png', 'fields' => array('POWATAG_QR' => array('title' => $this->l('QR Code enabled'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_QR_POS' => array('title' => $this->l('QR code Position'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => 'displayRightColumnProduct', 'name' => $this->l('displayRightColumnProduct')), array('key' => 'displayLeftColumnProduct', 'name' => $this->l('displayLeftColumnProduct')), array('key' => 'displayFooterProduct', 'name' => $this->l('displayFooterProduct')), array('key' => 'displayProductButtons', 'name' => $this->l('displayProductButtons'))), 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_SKU' => array('title' => $this->l('Which SKU field to use '), 'validation' => 'isInt', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => Powatag::EAN, 'name' => $this->l('EAN13 or JAN')), array('key' => Powatag::UPC, 'name' => $this->l('UPC')), array('key' => Powatag::PRODUCT_ID, 'name' => $this->l('Product ID')), array('key' => Powatag::REFERENCE, 'name' => $this->l('REFERENCE')))), 'POWATAG_REDIRECT' => array('title' => $this->l('URL Redirect'), 'validation' => 'isString', 'type' => 'text', 'size' => 250), 'POWATAG_OFFER' => array('title' => $this->l('Promotional area'), 'validation' => 'isString', 'type' => 'text', 'size' => 250), 'POWATAG_LANG' => array('title' => $this->l('Language'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'site', 'name' => $this->l('Use site language')), array('key' => 'en_GB', 'name' => $this->l('en_GB')), array('key' => 'es_ES', 'name' => $this->l('es_ES')), array('key' => 'fr_FR', 'name' => $this->l('fr_FR')), array('key' => 'it_IT', 'name' => $this->l('it_IT')))), 'POWATAG_TYPE' => array('title' => $this->l('Type'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'bag', 'name' => $this->l('Bag')), array('key' => 'mobile-button', 'name' => $this->l('Mobile button')), array('key' => 'tablet-bag', 'name' => $this->l('Tablet bag')))), 'POWATAG_STYLE' => array('title' => $this->l('Style'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'act-left', 'name' => $this->l('act-left')), array('key' => 'act-right', 'name' => $this->l('act-right')), array('key' => 'buy-left', 'name' => $this->l('buy-left')), array('key' => 'buy-right', 'name' => $this->l('buy-right')), array('key' => 'give-left', 'name' => $this->l('give-left')), array('key' => 'give-right', 'name' => $this->l('give-right')), array('key' => 'bg-act-left', 'name' => $this->l('bg-act-left')), array('key' => 'bg-act-right', 'name' => $this->l('bg-act-right')), array('key' => 'bg-buy-left', 'name' => $this->l('bg-buy-left')), array('key' => 'bg-buy-right', 'name' => $this->l('bg-buy-right')), array('key' => 'bg-give-left', 'name' => $this->l('bg-give-left')), array('key' => 'bg-give-right', 'name' => $this->l('bg-give-right')))), 'POWATAG_COLORSCHEME' => array('title' => $this->l('Color scheme'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'light', 'name' => $this->l('Light')), array('key' => 'dark', 'name' => $this->l('Dark')))), 'POWATAG_DISPLAY' => array('title' => $this->l('Desktop / mobile'), 'validation' => 'isString', 'type' => 'select', 'identifier' => 'key', 'list' => array(array('key' => '', 'name' => $this->l('Default')), array('key' => 'both', 'name' => $this->l('Both')), array('key' => 'desktop-only', 'name' => $this->l('Desktop only')), array('key' => 'mobile-only', 'name' => $this->l('Mobile only')))), 'POWATAG_VIDEO' => array('title' => $this->l('Video'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool'), 'POWATAG_DEBUG' => array('title' => $this->l('Developer mode'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool')), 'submit' => array('title' => $this->l('Save'))), 'logs' => array('title' => $this->l('Logs'), 'image' => '../img/t/AdminLogs.gif', 'fields' => array('POWATAG_API_LOG' => array('title' => $this->l('Enable applicative logging'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP), 'POWATAG_REQUEST_LOG' => array('title' => $this->l('Enable request logging'), 'validation' => 'isBool', 'cast' => 'intval', 'type' => 'bool', 'visibility' => Shop::CONTEXT_SHOP)), 'submit' => array('title' => $this->l('Save'))));
 }
    public function displayForm($isMainTab = true)
    {
        global $currentIndex;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        $carrierArray = array();
        $carriers = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, NULL, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
        $id_carrier = Tools::getValue('id_carrier', $obj->id_carrier);
        foreach ($carriers as $carrier) {
            if (!$carrier['is_free']) {
                $carrierArray[] = '<option value="' . (int) $carrier['id_carrier'] . '"' . ($carrier['id_carrier'] == $id_carrier ? ' selected="selected"' : '') . '>' . $carrier['name'] . '</option><sup>*</sup>';
            }
        }
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/t/AdminRangePrice.gif" />' . $this->l('Price ranges') . '</legend>
				<label>' . $this->l('Carrier') . '</label>
				<div class="margin-form">';
        if (count($carrierArray)) {
            echo '<select name="id_carrier">';
            foreach ($carrierArray as $carrierOption) {
                echo $carrierOption;
            }
            echo '</select>
				<p class="clear">' . $this->l('Carrier to which this range will be applied') . '</p>';
        } else {
            echo '<div style="margin:5px 0 10px 0">' . $this->l('There isn\'t any carrier available for a price range.') . '</div>';
        }
        echo '
				</div>
				<label>' . $this->l('From:') . ' </label>
				<div class="margin-form">
					' . $currency->getSign('left') . '<input type="text" size="4" name="delimiter1" value="' . htmlentities($this->getFieldValue($obj, 'delimiter1'), ENT_COMPAT, 'UTF-8') . '" />' . $currency->getSign('right') . '<sup>*</sup>
					<p class="clear">' . $this->l('Range start (included)') . '</p>
				</div>
				<label>' . $this->l('To:') . ' </label>
				<div class="margin-form">
					' . $currency->getSign('left') . '<input type="text" size="4" name="delimiter2" value="' . htmlentities($this->getFieldValue($obj, 'delimiter2'), ENT_COMPAT, 'UTF-8') . '" />' . $currency->getSign('right') . '<sup>*</sup>
					<p class="clear">' . $this->l('Range end (excluded)') . '</p>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
 public function getFormYaPokupki()
 {
     $yamodule = new Yamodule();
     $dir = _PS_ADMIN_DIR_;
     $dir = explode('/', $dir);
     $dir = base64_encode($yamodule->cryptor->encrypt(end($dir) . '_' . Context::getContext()->cookie->id_employee . '_pokupki'));
     $carriers = Carrier::getCarriers(Context::getContext()->language->id, true, false, false, null, 5);
     $type = array(array('name' => 'POST', 'id' => 'POST'), array('name' => 'PICKUP', 'id' => 'PICKUP'), array('name' => 'DELIVERY', 'id' => 'DELIVERY'));
     $out = array('form' => array('legend' => array('title' => $this->l('Module configuration Orders on the market'), 'icon' => 'icon-cogs'), 'input' => array(array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('A token for access to API Yandex.Market'), 'name' => 'YA_POKUPKI_TOKEN', 'label' => $this->l('An authorization token Yandex.Market')), array('col' => 4, 'class' => 't', 'disabled' => 1, 'type' => 'text', 'name' => 'YA_POKUPKI_FD', 'label' => $this->l('Формат данных')), array('col' => 4, 'class' => 't', 'disabled' => 1, 'type' => 'text', 'name' => 'YA_POKUPKI_TA', 'label' => $this->l('Тип авторизации')), array('type' => 'checkbox', 'label' => $this->l('Prepayment'), 'name' => 'YA_POKUPKI_PREDOPLATA', 'values' => array('query' => array(array('id' => 'YANDEX', 'name' => $this->l('Payment at registration (only in Russia)'), 'val' => 1), array('id' => 'SHOP_PREPAID', 'name' => $this->l('Directly to the shop (only for Ukraine)'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'label' => $this->l('Post-paid'), 'name' => 'YA_POKUPKI_POSTOPLATA', 'values' => array('query' => array(array('id' => 'CASH_ON_DELIVERY', 'name' => $this->l('Cash upon receipt of goods'), 'val' => 1), array('id' => 'CARD_ON_DELIVERY', 'name' => $this->l('Payment via credit card upon receipt of order'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'label' => $this->l('Settings'), 'name' => 'YA_POKUPKI_SET', 'values' => array('query' => array(array('id' => 'CHANGEC', 'name' => $this->l('To enable the change of delivery'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Ссылка на https://api.partner.market.yandex.ru/v2/'), 'name' => 'YA_POKUPKI_APIURL', 'label' => $this->l('URL affiliate API Yandex.Market')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('The Campaign Number'), 'name' => 'YA_POKUPKI_NC', 'label' => $this->l('The Campaign Number')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('The user login in the system Yandex.Market'), 'name' => 'YA_POKUPKI_LOGIN', 'label' => $this->l('The user login in the system Yandex.Market')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Application ID'), 'name' => 'YA_POKUPKI_ID', 'label' => $this->l('Application ID')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Password prilozheniye'), 'name' => 'YA_POKUPKI_PW', 'label' => $this->l('An application-specific password')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => '<a href="https://oauth.yandex.ru/authorize?response_type=code&display=popup&state=' . $dir . '&client_id=' . Configuration::get('YA_POKUPKI_ID') . "&device_id=" . md5(Configuration::get('YA_POKUPKI_ID')) . '">' . $this->l('To obtain a token for access to Yandex.Buy') . '</a>', 'name' => 'YA_POKUPKI_YATOKEN', 'label' => $this->l('An authorization token'), 'disabled' => true), array('col' => 6, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Item number ex'), 'name' => 'YA_POKUPKI_PUNKT', 'label' => $this->l('The ID of the item ex')), array('col' => 6, 'class' => 't', 'type' => 'text', 'name' => 'YA_MARKET_REDIRECT', 'desc' => $this->l('Callback Url for OAuth applications'), 'label' => $this->l('The link for the application')), array('col' => 6, 'class' => 't', 'type' => 'text', 'desc' => $this->l('URL API to fill in the store settings on Yandex.Market'), 'name' => 'YA_POKUPKI_APISHOP', 'label' => $this->l('The link to access Your store'))), 'submit' => array('title' => $this->l('Save'))));
     foreach ($carriers as $a) {
         $out['form']['input'][] = array('type' => 'select', 'label' => $this->l('The delivery type') . ' ' . $a['name'], 'name' => 'YA_POKUPKI_DELIVERY_' . $a['id_carrier'], 'desc' => $this->l('POST - Mail DELIVERY - Express delivery, PICKUP Pickup'), 'options' => array('query' => $type, 'name' => 'name', 'id' => 'id'), 'class' => 't');
     }
     return $out;
 }
 public function getContent()
 {
     if (Tools::isSubmit('btnSubmit')) {
         $this->postProcess();
     }
     $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
     $id_lang = Configuration::get('PS_LANG_DEFAULT');
     $carriers = Carrier::getCarriers($id_lang, false, false, false, null, 0);
     $config = Configuration::getMultiple(array('COD_ENABLED', 'COD_SHOW_ZERO', 'COD_TITLE', 'COD_ORDER_STATUS', 'COD_SPECIFIC_COUNTRY', 'COD_COUNTRY', 'COD_MINIMUM_ORDER', 'COD_MAXIMUM_ORDER', 'COD_COST_CALCULATION', 'COD_COST_INLAND', 'COD_COST_FOREIGN', 'COD_FREE_FROM', 'COD_CUSTOM_TEXT', 'COD_DISALLOW_METHODS', 'COD_DISALLOWED_METHODS', 'COD_ORDER_TIME'));
     $this->context->smarty->assign(array('module_name' => $this->name, 'displayName' => $this->displayName, 'order_time' => $config['COD_ORDER_TIME'], 'request_uri' => $_SERVER['REQUEST_URI'], 'enabled' => $config['COD_ENABLED'], 'show_zero' => $config['COD_SHOW_ZERO'], 'title' => $config['COD_TITLE'], 'orders_status' => OrderStateCore::getOrderStates((int) $this->context->language->id), 'order_status' => $config['COD_ORDER_STATUS'], 'specific_country' => $config['COD_SPECIFIC_COUNTRY'], 'country' => ($a = unserialize($config['COD_COUNTRY'])) ? $a : array(), 'all_countrys' => Country::getCountries((int) $this->context->language->id, true), 'minimum_order' => $config['COD_MINIMUM_ORDER'], 'maximum_order' => $config['COD_MAXIMUM_ORDER'], 'cost_calculation' => $config['COD_COST_CALCULATION'], 'cost_inland' => $config['COD_COST_INLAND'], 'cost_foreign' => $config['COD_COST_FOREIGN'], 'free_from' => $config['COD_FREE_FROM'], 'custom_text' => $config['COD_CUSTOM_TEXT'], 'disallow_methods' => $config['COD_DISALLOW_METHODS'], 'carriers' => $carriers, 'disallowed_methods' => ($a = unserialize($config['COD_DISALLOWED_METHODS'])) ? $a : array(), 'currency_sign' => $currency->sign));
     $this->context->controller->addJS($this->local_path . '/views/js/script.js', 'all');
     $output = $this->context->smarty->fetch($this->local_path . '/views/templates/admin/configure.tpl');
     return $output;
 }
 public function __construct()
 {
     global $cookie;
     $this->table = 'carrier';
     $this->className = 'Carrier';
     $this->lang = true;
     $this->edit = true;
     $this->delete = true;
     $this->deleted = true;
     $this->fieldImageSettings = array('name' => 'logo', 'dir' => 's');
     $this->fieldsDisplay = array('id_carrier' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name'), 'width' => 100), 'logo' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 's', 'orderby' => false, 'search' => false), 'delay' => array('title' => $this->l('Delay'), 'width' => 300, 'orderby' => false), 'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false), 'is_free' => array('title' => $this->l('Is Free'), 'align' => 'center', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif', 'default' => 'disabled.gif'), 'type' => 'bool', 'orderby' => false));
     $this->optionTitle = $this->l('Carrier options');
     $this->_fieldsOptions = array('PS_CARRIER_DEFAULT' => array('title' => $this->l('Default carrier:'), 'desc' => $this->l('The default carrier used in shop'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_carrier', 'list' => Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, NULL, Carrier::ALL_CARRIERS)));
     parent::__construct();
 }
 public function getFormYaPokupki()
 {
     $state = OrderState::getOrderStates(Context::getContext()->language->id);
     $dir = _PS_ADMIN_DIR_;
     $dir = explode('/', $dir);
     $dir = base64_encode(end($dir) . '_' . Context::getContext()->cookie->id_employee . '_pokupki');
     $extend = array();
     $carriers = Carrier::getCarriers(Context::getContext()->language->id, true, false, false, null, 5);
     $type = array(array('name' => 'POST', 'id' => 'POST'), array('name' => 'PICKUP', 'id' => 'PICKUP'), array('name' => 'DELIVERY', 'id' => 'DELIVERY'));
     $out = array('form' => array('legend' => array('title' => $this->l('Настройки модуля Заказы на маркете'), 'icon' => 'icon-cogs'), 'input' => array(array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Токен для доступа к API Яндекс.Маркет'), 'name' => 'YA_POKUPKI_TOKEN', 'label' => $this->l('Авторизационный токен Яндекс.Маркет')), array('type' => 'checkbox', 'label' => $this->l('Предоплата'), 'name' => 'YA_POKUPKI_PREDOPLATA', 'values' => array('query' => array(array('id' => 'YANDEX', 'name' => $this->l('Оплата при оформлении (только в России)'), 'val' => 1), array('id' => 'SHOP_PREPAID', 'name' => $this->l('Напрямую магазину (только для Украины)'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'label' => $this->l('Постоплата'), 'name' => 'YA_POKUPKI_POSTOPLATA', 'values' => array('query' => array(array('id' => 'CASH_ON_DELIVERY', 'name' => $this->l('Наличный расчёт при получении товара'), 'val' => 1), array('id' => 'CARD_ON_DELIVERY', 'name' => $this->l('Оплата банковской картой при получении заказа'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('type' => 'checkbox', 'label' => $this->l('Настройки'), 'name' => 'YA_POKUPKI_SET', 'values' => array('query' => array(array('id' => 'CHANGEC', 'name' => $this->l('Включить смену доставок'), 'val' => 1)), 'id' => 'id', 'name' => 'name')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Ссылка на https://api.partner.market.yandex.ru/v2/'), 'name' => 'YA_POKUPKI_APIURL', 'label' => $this->l('URL партнёрского API Яндекс.Маркет')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Номер Кампании'), 'name' => 'YA_POKUPKI_NC', 'label' => $this->l('Номер Кампании')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Логин пользователя в системе Яндекс.Маркет'), 'name' => 'YA_POKUPKI_LOGIN', 'label' => $this->l('Логин пользователя в системе Яндекс.Маркет')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('ID приложения'), 'name' => 'YA_POKUPKI_ID', 'label' => $this->l('ID приложения')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Пароль приложениюж'), 'name' => 'YA_POKUPKI_PW', 'label' => $this->l('Пароль приложения')), array('col' => 4, 'class' => 't', 'type' => 'text', 'desc' => '<a href="https://oauth.yandex.ru/authorize?response_type=code&display=popup&state=' . $dir . '&client_id=' . Configuration::get('YA_POKUPKI_ID') . "&device_id=" . md5(Configuration::get('YA_POKUPKI_ID')) . '">' . $this->l('Получить токен для доступа к Yandex.Покупки') . '</a>', 'name' => 'YA_POKUPKI_YATOKEN', 'label' => $this->l('Авторизационный токен'), 'disabled' => true), array('col' => 6, 'class' => 't', 'type' => 'text', 'desc' => $this->l('Номер пункта самовывоза'), 'name' => 'YA_POKUPKI_PUNKT', 'label' => $this->l('Идентификатор пункта самовывоза')), array('col' => 6, 'class' => 't', 'type' => 'text', 'name' => 'YA_MARKET_REDIRECT', 'desc' => $this->l('Callback Url для OAuth-приложения'), 'label' => $this->l('Ссылка для приложения')), array('col' => 6, 'class' => 't', 'type' => 'text', 'desc' => $this->l('URL API для заполнения в настройках магазина на Яндекс.Маркет'), 'name' => 'YA_POKUPKI_APISHOP', 'label' => $this->l('Ссылка для обращения к Вашему магазину'))), 'submit' => array('title' => $this->l('Сохранить'))));
     foreach ($carriers as $a) {
         $out['form']['input'][] = array('type' => 'select', 'label' => $this->l('Тип доставки') . ' ' . $a['name'], 'name' => 'YA_POKUPKI_DELIVERY_' . $a['id_carrier'], 'desc' => $this->l('POST - Почта, DELIVERY - Курьерская доставка, PICKUP - Самовывоз'), 'options' => array('query' => $type, 'name' => 'name', 'id' => 'id'), 'class' => 't');
     }
     return $out;
 }
 public function postProcess()
 {
     $return = parent::postProcess();
     if (Tools::getValue('submitAdd' . $this->table) && Validate::isLoadedObject($return)) {
         $carriers = Carrier::getCarriers($this->context->language->iso_code, false, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
         $carrier_box = array();
         foreach ($carriers as $carrier) {
             if (Tools::getIsset('carrierBox_' . $carrier['id_carrier'])) {
                 $carrier_box[] = $carrier['id_carrier'];
             }
         }
         $return->updateCarriers($carrier_box);
         $return->updateGroups(Tools::getValue('groupBox'));
     }
     return $return;
 }
    public function __construct()
    {
        parent::__construct();
        $this->table = 'delivery';
        $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
        foreach ($carriers as $key => $carrier) {
            if ($carrier['is_free']) {
                unset($carriers[$key]);
            }
        }
        $carrier_default_sort = array(array('value' => Carrier::SORT_BY_PRICE, 'name' => $this->l('Price')), array('value' => Carrier::SORT_BY_POSITION, 'name' => $this->l('Position')));
        $carrier_default_order = array(array('value' => Carrier::SORT_BY_ASC, 'name' => $this->l('Ascending')), array('value' => Carrier::SORT_BY_DESC, 'name' => $this->l('Descending')));
        $this->fields_options = array('handling' => array('title' => $this->l('Handling'), 'icon' => 'delivery', 'fields' => array('PS_SHIPPING_HANDLING' => array('title' => $this->l('Handling charges'), 'suffix' => $this->context->currency->getSign() . ' ' . $this->l('(tax excl.)'), 'cast' => 'floatval', 'type' => 'text', 'validation' => 'isPrice'), 'PS_SHIPPING_FREE_PRICE' => array('title' => $this->l('Free shipping starts at'), 'suffix' => $this->context->currency->getSign(), 'cast' => 'floatval', 'type' => 'text', 'validation' => 'isPrice'), 'PS_SHIPPING_FREE_WEIGHT' => array('title' => $this->l('Free shipping starts at'), 'suffix' => Configuration::get('PS_WEIGHT_UNIT'), 'cast' => 'floatval', 'type' => 'text', 'validation' => 'isUnsignedFloat')), 'description' => '<ul>
						<li>' . $this->l('If you set these parameters to 0, they will be disabled.') . '</li>
						<li>' . $this->l('Coupons are not taken into account when calculating free shipping') . '</li>
					</ul>', 'submit' => array()), 'general' => array('title' => $this->l('Carrier options'), 'fields' => array('PS_CARRIER_DEFAULT' => array('title' => $this->l('Default carrier:'), 'desc' => $this->l('Your shop\'s default carrier'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_carrier', 'list' => array_merge(array(-1 => array('id_carrier' => -1, 'name' => $this->l('Best price')), -2 => array('id_carrier' => -2, 'name' => $this->l('Best grade'))), Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, null, Carrier::ALL_CARRIERS))), 'PS_CARRIER_DEFAULT_SORT' => array('title' => $this->l('Sort by:'), 'desc' => $this->l('This will only be visible in the Front Office'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => $carrier_default_sort), 'PS_CARRIER_DEFAULT_ORDER' => array('title' => $this->l('Order by:'), 'desc' => $this->l('This will only be visible in the Front Office'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => $carrier_default_order)), 'submit' => array()));
    }
 public function __construct()
 {
     $this->table = 'carrier';
     $this->className = 'Carrier';
     $this->lang = false;
     $this->deleted = true;
     $this->addRowAction('edit');
     $this->addRowAction('delete');
     $this->_defaultOrderBy = 'position';
     $this->context = Context::getContext();
     $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Are you sure that you want to delete the selected items?')), 'enableSelection' => array('text' => $this->l('Enable selection')), 'disableSelection' => array('text' => $this->l('Disable selection')));
     $this->fieldImageSettings = array('name' => 'logo', 'dir' => 's');
     $this->fields_list = array('id_carrier' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name'), 'width' => 'auto'), 'image' => array('title' => $this->l('Logo'), 'align' => 'center', 'image' => 's', 'orderby' => false, 'search' => false, 'width' => 120), 'delay' => array('title' => $this->l('Delay'), 'width' => 300, 'orderby' => false), 'active' => array('title' => $this->l('Status'), 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false, 'width' => 25), 'is_free' => array('title' => $this->l('Free Shipping'), 'align' => 'center', 'icon' => array(0 => 'disabled.gif', 1 => 'enabled.gif', 'default' => 'disabled.gif'), 'type' => 'bool', 'orderby' => false, 'width' => 150), 'position' => array('title' => $this->l('Position'), 'width' => 40, 'filter_key' => 'a!position', 'align' => 'center', 'position' => 'position'));
     $carrier_default_sort = array(array('value' => Carrier::SORT_BY_PRICE, 'name' => $this->l('Price')), array('value' => Carrier::SORT_BY_POSITION, 'name' => $this->l('Position')));
     $carrier_default_order = array(array('value' => Carrier::SORT_BY_ASC, 'name' => $this->l('Ascending')), array('value' => Carrier::SORT_BY_DESC, 'name' => $this->l('Descending')));
     $this->fields_options = array('general' => array('title' => $this->l('Carrier options'), 'fields' => array('PS_CARRIER_DEFAULT' => array('title' => $this->l('Default carrier:'), 'desc' => $this->l('Your shop\'s default carrier'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'id_carrier', 'list' => array_merge(array(-1 => array('id_carrier' => -1, 'name' => $this->l('Best price')), -2 => array('id_carrier' => -2, 'name' => $this->l('Best grade'))), Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, null, Carrier::ALL_CARRIERS))), 'PS_CARRIER_DEFAULT_SORT' => array('title' => $this->l('Sort by:'), 'desc' => $this->l('This will only be visible in the Front Office'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => $carrier_default_sort), 'PS_CARRIER_DEFAULT_ORDER' => array('title' => $this->l('Order by:'), 'desc' => $this->l('This will only be visible in the Front Office'), 'cast' => 'intval', 'type' => 'select', 'identifier' => 'value', 'list' => $carrier_default_order)), 'submit' => array()));
     parent::__construct();
 }
    public function displayForm($isMainTab = true)
    {
        global $currentIndex;
        parent::displayForm();
        if (!($obj = $this->loadObject(true))) {
            return;
        }
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/t/AdminRangeWeight.gif" />' . $this->l('Weight ranges') . '</legend>
				<label>' . $this->l('Carrier') . '</label>
				<div class="margin-form">
					<select name="id_carrier">';
        $carriers = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, NULL, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
        $id_carrier = Tools::getValue('id_carrier', $obj->id_carrier);
        foreach ($carriers as $carrier) {
            echo '<option value="' . (int) $carrier['id_carrier'] . '"' . ($carrier['id_carrier'] == $id_carrier ? ' selected="selected"' : '') . '>' . $carrier['name'] . '</option><sup>*</sup>';
        }
        echo '
					</select>
					<p class="clear">' . $this->l('Carrier to which this range will be applied') . '</p>
				</div>
				<label>' . $this->l('From:') . ' </label>
				<div class="margin-form">
					<input type="text" size="4" name="delimiter1" value="' . htmlentities($this->getFieldValue($obj, 'delimiter1'), ENT_COMPAT, 'UTF-8') . '" /> ' . Configuration::get('PS_WEIGHT_UNIT') . ' <sup>*</sup>
					<p class="clear">' . $this->l('Range start (included)') . '</p>
				</div>
				<label>' . $this->l('To:') . ' </label>
				<div class="margin-form">
					<input type="text" size="4" name="delimiter2" value="' . htmlentities($this->getFieldValue($obj, 'delimiter2'), ENT_COMPAT, 'UTF-8') . '" /> ' . Configuration::get('PS_WEIGHT_UNIT') . ' <sup>*</sup>
					<p class="clear">' . $this->l('Range end (excluded)') . '</p>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
    public function displayForm($isMainTab = true)
    {
        global $currentIndex;
        parent::displayForm();
        $obj = $this->loadObject(true);
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        echo '
		<form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post" class="width2">
		' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . '
			<fieldset><legend><img src="../img/t/AdminRangePrice.gif" />' . $this->l('Price ranges') . '</legend>
				<label>' . $this->l('Carrier:') . '</label>
				<div class="margin-form">
					<select name="id_carrier">';
        $carriers = Carrier::getCarriers(intval(Configuration::get('PS_LANG_DEFAULT')));
        $id_carrier = Tools::getValue('id_carrier', $obj->id_carrier);
        foreach ($carriers as $carrier) {
            echo '<option value="' . intval($carrier['id_carrier']) . '"' . ($carrier['id_carrier'] == $id_carrier ? ' selected="selected"' : '') . '>' . $carrier['name'] . '</option><sup>*</sup>';
        }
        echo '
					</select>
					<p class="clear">' . $this->l('Carrier to which this range will be applied') . '</p>
				</div>
				<label>' . $this->l('From:') . ' </label>
				<div class="margin-form">
					' . $currency->getSign('left') . '<input type="text" size="4" name="delimiter1" value="' . htmlentities($this->getFieldValue($obj, 'delimiter1'), ENT_COMPAT, 'UTF-8') . '" />' . $currency->getSign('right') . '<sup>*</sup>
					<p class="clear">' . $this->l('Range start (included)') . '</p>
				</div>
				<label>' . $this->l('To:') . ' </label>
				<div class="margin-form">
					' . $currency->getSign('left') . '<input type="text" size="4" name="delimiter2" value="' . htmlentities($this->getFieldValue($obj, 'delimiter2'), ENT_COMPAT, 'UTF-8') . '" />' . $currency->getSign('right') . '<sup>*</sup>
					<p class="clear">' . $this->l('Range end (excluded)') . '</p>
				</div>
				<div class="margin-form">
					<input type="submit" value="' . $this->l('   Save   ') . '" name="submitAdd' . $this->table . '" class="button" />
				</div>
				<div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div>
			</fieldset>
		</form>';
    }
Beispiel #26
0
    public function getCarriers($id_lang, $active = false, $delete = false, $id_zone = false, $ids_group = null, $modules_filters = 1)
    {
        $carriers = Carrier::getCarriers($id_lang, $active, $delete, $id_zone, $ids_group, $modules_filters);
        if (version_compare(_PS_VERSION_, '1.5', '>')) {
            $sql = 'SELECT `id_carrier`
				FROM `' . _DB_PREFIX_ . 'carrier_shop`
				WHERE `id_shop` = ' . (int) $this->id_shop;
        } else {
            $sql = 'SELECT `id_carrier`
				FROM `' . _DB_PREFIX_ . 'carrier`';
        }
        $res = Db::getInstance()->executeS($sql);
        $id_carriers = array();
        foreach ($res as $row) {
            $id_carriers[] = $row['id_carrier'];
        }
        $final_carriers = array();
        foreach ($carriers as $carrier) {
            if (in_array($carrier['id_carrier'], $id_carriers)) {
                $final_carriers[] = $carrier;
            }
        }
        return $final_carriers;
    }
Beispiel #27
0
 /**
  * Get available Carriers for Order
  *
  * @param int       $id_zone Zone ID
  * @param array     $groups  Group of the Customer
  * @param Cart|null $cart    Optional Cart object
  * @param array     &$error  Contains an error message if an error occurs
  *
  * @return array Carriers for the order
  */
 public static function getCarriersForOrder($id_zone, $groups = null, $cart = null, &$error = array())
 {
     $context = Context::getContext();
     $id_lang = $context->language->id;
     if (is_null($cart)) {
         $cart = $context->cart;
     }
     if (isset($context->currency)) {
         $id_currency = $context->currency->id;
     }
     if (is_array($groups) && !empty($groups)) {
         $result = Carrier::getCarriers($id_lang, true, false, (int) $id_zone, $groups, self::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     } else {
         $result = Carrier::getCarriers($id_lang, true, false, (int) $id_zone, array(Configuration::get('PS_UNIDENTIFIED_GROUP')), self::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
     }
     $results_array = array();
     foreach ($result as $k => $row) {
         $carrier = new Carrier((int) $row['id_carrier']);
         $shipping_method = $carrier->getShippingMethod();
         if ($shipping_method != Carrier::SHIPPING_METHOD_FREE) {
             // Get only carriers that are compliant with shipping method
             if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight($id_zone) === false) {
                 $error[$carrier->id] = Carrier::SHIPPING_WEIGHT_EXCEPTION;
                 unset($result[$k]);
                 continue;
             }
             if ($shipping_method == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice($id_zone) === false) {
                 $error[$carrier->id] = Carrier::SHIPPING_PRICE_EXCEPTION;
                 unset($result[$k]);
                 continue;
             }
             // If out-of-range behavior carrier is set to "Deactivate carrier"
             if ($row['range_behavior']) {
                 // Get id zone
                 if (!$id_zone) {
                     $id_zone = (int) Country::getIdZone(Country::getDefaultCountryId());
                 }
                 // Get only carriers that have a range compatible with cart
                 if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $cart->getTotalWeight(), $id_zone)) {
                     $error[$carrier->id] = Carrier::SHIPPING_WEIGHT_EXCEPTION;
                     unset($result[$k]);
                     continue;
                 }
                 if ($shipping_method == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING), $id_zone, $id_currency)) {
                     $error[$carrier->id] = Carrier::SHIPPING_PRICE_EXCEPTION;
                     unset($result[$k]);
                     continue;
                 }
             }
         }
         $row['name'] = strval($row['name']) != '0' ? $row['name'] : Carrier::getCarrierNameFromShopName();
         $row['price'] = $shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int) $row['id_carrier'], true, null, null, $id_zone);
         $row['price_tax_exc'] = $shipping_method == Carrier::SHIPPING_METHOD_FREE ? 0 : $cart->getPackageShippingCost((int) $row['id_carrier'], false, null, null, $id_zone);
         $row['img'] = file_exists(_PS_SHIP_IMG_DIR_ . (int) $row['id_carrier'] . '.jpg') ? _THEME_SHIP_DIR_ . (int) $row['id_carrier'] . '.jpg' : '';
         // If price is false, then the carrier is unavailable (carrier module)
         if ($row['price'] === false) {
             unset($result[$k]);
             continue;
         }
         $results_array[] = $row;
     }
     // if we have to sort carriers by price
     $prices = array();
     if (Configuration::get('PS_CARRIER_DEFAULT_SORT') == Carrier::SORT_BY_PRICE) {
         foreach ($results_array as $r) {
             $prices[] = $r['price'];
         }
         if (Configuration::get('PS_CARRIER_DEFAULT_ORDER') == Carrier::SORT_BY_ASC) {
             array_multisort($prices, SORT_ASC, SORT_NUMERIC, $results_array);
         } else {
             array_multisort($prices, SORT_DESC, SORT_NUMERIC, $results_array);
         }
     }
     return $results_array;
 }
 private function _getCarriersSelect($configuration, $actual_value, $name = 'SHOPPING_FLUX_CARRIER')
 {
     $html = '<select name="' . Tools::safeOutput($name) . '">';
     foreach (Carrier::getCarriers($configuration['PS_LANG_DEFAULT'], true, false, false, null, 5) as $carrier) {
         $selected = (int) $actual_value === (int) $carrier['id_reference'] ? 'selected = "selected"' : '';
         $html .= '<option value="' . (int) $carrier['id_reference'] . '" ' . $selected . '>' . Tools::safeOutput($carrier['name']) . '</option>';
     }
     $html .= '</select>';
     return $html;
 }
Beispiel #29
0
 public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null)
 {
     if (!Configuration::get('LEGAL_SHIPTAXMETH')) {
         return parent::getPackageShippingCost($id_carrier, $use_tax, $default_country, $product_list, $id_zone);
     }
     if ($this->isVirtualCart()) {
         return 0;
     }
     if (!$default_country) {
         $default_country = Context::getContext()->country;
     }
     if (!is_null($product_list)) {
         foreach ($product_list as $key => $value) {
             if ($value['is_virtual'] == 1) {
                 unset($product_list[$key]);
             }
         }
     }
     $complete_product_list = $this->getProducts();
     if (is_null($product_list)) {
         $products = $complete_product_list;
     } else {
         $products = $product_list;
     }
     if (Configuration::get('PS_TAX_ADDRESS_TYPE') == 'id_address_invoice') {
         $address_id = (int) $this->id_address_invoice;
     } elseif (count($product_list)) {
         $prod = current($product_list);
         $address_id = (int) $prod['id_address_delivery'];
     } else {
         $address_id = null;
     }
     if (!Address::addressExists($address_id)) {
         $address_id = null;
     }
     $cache_id = 'getPackageShippingCost_' . (int) $this->id . '_' . (int) $address_id . '_' . (int) $id_carrier . '_' . (int) $use_tax . '_' . (int) $default_country->id;
     if ($products) {
         foreach ($products as $product) {
             $cache_id .= '_' . (int) $product['id_product'] . '_' . (int) $product['id_product_attribute'];
         }
     }
     if (Cache::isStored($cache_id)) {
         return Cache::retrieve($cache_id);
     }
     // Order total in default currency without fees
     $order_total = $this->getOrderTotal(true, Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING, $product_list);
     // Start with shipping cost at 0
     $shipping_cost = 0;
     // If no product added, return 0
     if (!count($products)) {
         Cache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     if (!isset($id_zone)) {
         // Get id zone
         if (!$this->isMultiAddressDelivery() && isset($this->id_address_delivery) && $this->id_address_delivery && Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) {
             $id_zone = Address::getZoneById((int) $this->id_address_delivery);
         } else {
             if (!Validate::isLoadedObject($default_country)) {
                 $default_country = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
             }
             $id_zone = (int) $default_country->id_zone;
         }
     }
     if ($id_carrier && !$this->isCarrierInRange((int) $id_carrier, (int) $id_zone)) {
         $id_carrier = '';
     }
     if (empty($id_carrier) && $this->isCarrierInRange((int) Configuration::get('PS_CARRIER_DEFAULT'), (int) $id_zone)) {
         $id_carrier = (int) Configuration::get('PS_CARRIER_DEFAULT');
     }
     $total_package_without_shipping_tax_inc = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $product_list);
     if (empty($id_carrier)) {
         if ((int) $this->id_customer) {
             $customer = new Customer((int) $this->id_customer);
             $result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone, $customer->getGroups());
             unset($customer);
         } else {
             $result = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, (int) $id_zone);
         }
         foreach ($result as $k => $row) {
             if ($row['id_carrier'] == Configuration::get('PS_CARRIER_DEFAULT')) {
                 continue;
             }
             if (!isset(self::$_carriers[$row['id_carrier']])) {
                 self::$_carriers[$row['id_carrier']] = new Carrier((int) $row['id_carrier']);
             }
             $carrier = self::$_carriers[$row['id_carrier']];
             // Get only carriers that are compliant with shipping method
             if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && $carrier->getMaxDeliveryPriceByWeight((int) $id_zone) === false || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && $carrier->getMaxDeliveryPriceByPrice((int) $id_zone) === false) {
                 unset($result[$k]);
                 continue;
             }
             // If out-of-range behavior carrier is set on "Desactivate carrier"
             if ($row['range_behavior']) {
                 $check_delivery_price_by_weight = Carrier::checkDeliveryPriceByWeight($row['id_carrier'], $this->getTotalWeight(), (int) $id_zone);
                 $total_order = $total_package_without_shipping_tax_inc;
                 $check_delivery_price_by_price = Carrier::checkDeliveryPriceByPrice($row['id_carrier'], $total_order, (int) $id_zone, (int) $this->id_currency);
                 // Get only carriers that have a range compatible with cart
                 if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !$check_delivery_price_by_weight || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !$check_delivery_price_by_price) {
                     unset($result[$k]);
                     continue;
                 }
             }
             if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
                 $shipping = $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), (int) $id_zone);
             } else {
                 $shipping = $carrier->getDeliveryPriceByPrice($order_total, (int) $id_zone, (int) $this->id_currency);
             }
             if (!isset($min_shipping_price)) {
                 $min_shipping_price = $shipping;
             }
             if ($shipping <= $min_shipping_price) {
                 $id_carrier = (int) $row['id_carrier'];
                 $min_shipping_price = $shipping;
             }
         }
     }
     if (empty($id_carrier)) {
         $id_carrier = Configuration::get('PS_CARRIER_DEFAULT');
     }
     if (!isset(self::$_carriers[$id_carrier])) {
         self::$_carriers[$id_carrier] = new Carrier((int) $id_carrier, Configuration::get('PS_LANG_DEFAULT'));
     }
     $carrier = self::$_carriers[$id_carrier];
     // No valid Carrier or $id_carrier <= 0 ?
     if (!Validate::isLoadedObject($carrier)) {
         Cache::store($cache_id, 0);
         return 0;
     }
     if (!$carrier->active) {
         Cache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     // Free fees if free carrier
     if ($carrier->is_free == 1) {
         Cache::store($cache_id, 0);
         return 0;
     }
     // Select carrier tax
     if ($use_tax && !Tax::excludeTaxeOption()) {
         $address = Address::initialize((int) $address_id);
         $carrier_tax = $carrier->getTaxesRate($address);
     }
     $configuration = Configuration::getMultiple(array('PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT'));
     // Free fees
     $free_fees_price = 0;
     if (isset($configuration['PS_SHIPPING_FREE_PRICE'])) {
         $free_fees_price = Tools::convertPrice((double) $configuration['PS_SHIPPING_FREE_PRICE'], Currency::getCurrencyInstance((int) $this->id_currency));
     }
     $orderTotalwithDiscounts = $this->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, null, null, false);
     if ($orderTotalwithDiscounts >= (double) $free_fees_price && (double) $free_fees_price > 0) {
         Cache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     if (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) && $this->getTotalWeight() >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] && (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) {
         Cache::store($cache_id, $shipping_cost);
         return $shipping_cost;
     }
     // Get shipping cost using correct method
     if ($carrier->range_behavior) {
         if (!isset($id_zone)) {
             // Get id zone
             if (isset($this->id_address_delivery) && $this->id_address_delivery && Customer::customerHasAddress($this->id_customer, $this->id_address_delivery)) {
                 $id_zone = Address::getZoneById((int) $this->id_address_delivery);
             } else {
                 $id_zone = (int) $default_country->id_zone;
             }
         }
         if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT && !Carrier::checkDeliveryPriceByWeight($carrier->id, $this->getTotalWeight(), (int) $id_zone) || $carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_PRICE && !Carrier::checkDeliveryPriceByPrice($carrier->id, $total_package_without_shipping_tax_inc, $id_zone, (int) $this->id_currency)) {
             $shipping_cost += 0;
         } else {
             if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
                 $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
             } else {
                 // by price
                 $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency);
             }
         }
     } else {
         if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
             $shipping_cost += $carrier->getDeliveryPriceByWeight($this->getTotalWeight($product_list), $id_zone);
         } else {
             $shipping_cost += $carrier->getDeliveryPriceByPrice($order_total, $id_zone, (int) $this->id_currency);
         }
     }
     // Adding handling charges
     if (isset($configuration['PS_SHIPPING_HANDLING']) && $carrier->shipping_handling) {
         $shipping_cost += (double) $configuration['PS_SHIPPING_HANDLING'];
     }
     // Additional Shipping Cost per product
     foreach ($products as $product) {
         if (!$product['is_virtual']) {
             $shipping_cost += $product['additional_shipping_cost'] * $product['cart_quantity'];
         }
     }
     $shipping_cost = Tools::convertPrice($shipping_cost, Currency::getCurrencyInstance((int) $this->id_currency));
     //get external shipping cost from module
     if ($carrier->shipping_external) {
         $module_name = $carrier->external_module_name;
         $module = Module::getInstanceByName($module_name);
         if (Validate::isLoadedObject($module)) {
             if (array_key_exists('id_carrier', $module)) {
                 $module->id_carrier = $carrier->id;
             }
             if ($carrier->need_range) {
                 if (method_exists($module, 'getPackageShippingCost')) {
                     $shipping_cost = $module->getPackageShippingCost($this, $shipping_cost, $products);
                 } else {
                     $shipping_cost = $module->getOrderShippingCost($this, $shipping_cost);
                 }
             } else {
                 $shipping_cost = $module->getOrderShippingCostExternal($this);
             }
             // Check if carrier is available
             if ($shipping_cost === false) {
                 Cache::store($cache_id, false);
                 return false;
             }
         } else {
             Cache::store($cache_id, false);
             return false;
         }
     }
     $shipping_cost = (double) Tools::ps_round((double) $shipping_cost, 2);
     Cache::store($cache_id, $shipping_cost);
     return $shipping_cost;
 }
 private function uninstallCarrier($carrierId)
 {
     //$carrierId = $this->carrierId();
     if (!is_null($carrierId)) {
         $carrier = new Carrier($carrierId);
         $langDefault = (int) Configuration::get('PS_LANG_DEFAULT');
         $carriers = Carrier::getCarriers($langDefault, true, false, false, NULL, PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
         // Если наш перевозчик был по умолчанию, назначим кого-нибудь другого
         if (Configuration::get('PS_CARRIER_DEFAULT') == $carrierId) {
             foreach ($carriers as $c) {
                 if ($c['active'] && !$c['deleted'] && $c['name'] != $carrier->name) {
                     Configuration::updateValue('PS_CARRIER_DEFAULT', $c['id_carrier']);
                 }
             }
         }
         if (!$carrier->deleted) {
             $carrier->deleted = 1;
             if (!$carrier->update()) {
                 return false;
             }
         }
     }
     return true;
 }