当前位置: 首页>>代码示例>>PHP>>正文


PHP RangeWeight::add方法代码示例

本文整理汇总了PHP中RangeWeight::add方法的典型用法代码示例。如果您正苦于以下问题:PHP RangeWeight::add方法的具体用法?PHP RangeWeight::add怎么用?PHP RangeWeight::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RangeWeight的用法示例。


在下文中一共展示了RangeWeight::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createDejalaCarrier

 /**
  * creates of a dejala carrier corresponding to $dejalaProduct
  */
 public static function createDejalaCarrier($dejalaConfig, $dejalaProduct)
 {
     // MFR091130 - get id zone from the country used in the module (if the store zones were customized) - default is 1 (Europe)
     $id_zone = 1;
     $moduleCountryIsoCode = strtoupper($dejalaConfig->country);
     $countryID = Country::getByIso($moduleCountryIsoCode);
     if (intval($countryID)) {
         $id_zone = Country::getIdZone($countryID);
     }
     $vatRate = floatval($dejalaProduct['vat']);
     // MFR091130 - get or create the tax & attach it to our zone if needed
     $id_tax = Tax::getTaxIdByRate($vatRate);
     if (!$id_tax) {
         $tax = new Tax();
         $tax->rate = $vatRate;
         $defaultLanguage = Configuration::get('PS_LANG_DEFAULT');
         $tax->name[$defaultLanguage] = $tax->rate . '%';
         $tax->add();
         $id_tax = Tax::getTaxIdByRate($vatRate);
     }
     if (!Tax::zoneHasTax($id_tax, $id_zone)) {
         // MFR : direct call because $tax->addZone($id_zone) causes errors when called
         Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'tax_zone` (`id_tax` , `id_zone`) VALUES (' . intval($id_tax) . ', ' . intval($id_zone) . ')');
     }
     $carrier = new Carrier();
     $carrier->name = 'dejala';
     $carrier->id_tax = $id_tax;
     $carrier->url = 'http://tracking.dejala.' . $dejalaConfig->country . '/tracker/@';
     $carrier->active = true;
     $carrier->deleted = 0;
     $carrier->shipping_handling = false;
     $carrier->range_behavior = 0;
     $carrier->is_module = 1;
     $languages = Language::getLanguages(true);
     foreach ($languages as $language) {
         if ($language['iso_code'] == 'fr') {
             $carrier->delay[$language['id_lang']] = utf8_encode('Quand vous voulez... Par coursier, ' . $dejalaProduct['timelimit'] . 'H');
         }
         if ($language['iso_code'] == 'en') {
             $carrier->delay[$language['id_lang']] = utf8_encode('When you want... Dispatch rider, ' . $dejalaProduct['timelimit'] . 'H range');
         }
         if ($language['iso_code'] == 'es') {
             $carrier->delay[$language['id_lang']] = utf8_encode('Cuando quiera... Por mensajero, ' . $dejalaProduct['timelimit'] . 'H');
         }
     }
     $carrier->add();
     $sql = 'INSERT INTO `' . _DB_PREFIX_ . 'carrier_zone` (`id_carrier` , `id_zone`) VALUES (' . intval($carrier->id) . ', ' . intval($id_zone) . ')';
     Db::getInstance()->Execute($sql);
     $rangeW = new RangeWeight();
     $rangeW->id_carrier = $carrier->id;
     $rangeW->delimiter1 = 0;
     $rangeW->delimiter2 = $dejalaProduct['max_weight'];
     $rangeW->add();
     $vat_factor = 1 + $dejalaProduct['vat'] / 100;
     $priceTTC = round($dejalaProduct['price'] * $vat_factor + $dejalaProduct['margin'], 2);
     $priceHT = round($priceTTC / $vat_factor, 2);
     $priceList = '(NULL' . ',' . $rangeW->id . ',' . $carrier->id . ',' . $id_zone . ',' . $priceHT . ')';
     $carrier->addDeliveryPrice($priceList);
     return new Carrier($carrier->id);
 }
开发者ID:vincent,项目名称:theinvertebrates,代码行数:63,代码来源:dejalacarrierutils.php

示例2: xdInstall

 public function xdInstall()
 {
     foreach ($this->Options->getValue('carrierList') as $carrier_key => $carrier_name) {
         $carrierId = \Configuration::get($carrier_key);
         $deleted = false;
         if ($carrierId > 0) {
             $carrier = new \Carrier($carrierId);
             $deleted = $carrier->deleted;
         }
         if ($carrierId < 1 || $deleted) {
             // Create carrier
             $carrier = new \Carrier();
             $carrier->name = $carrier_name;
             $carrier->id_tax_rules_group = 0;
             $carrier->active = 1;
             $carrier->deleted = 0;
             foreach (\Language::getLanguages(true) as $language) {
                 // TODO Carrier delay
                 $carrier->delay[(int) $language['id_lang']] = ' ';
             }
             $carrier->shipping_handling = 0;
             $carrier->range_behavior = 1;
             $carrier->is_module = 1;
             $carrier->shipping_external = 1;
             $carrier->external_module_name = $this->moduleInstance->name;
             $carrier->need_range = 1;
             if (!$carrier->add()) {
                 return false;
             }
             // Associate carrier to all groups
             $groups = \Group::getGroups(true);
             foreach ($groups as $group) {
                 \Db::getInstance()->insert('carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']));
             }
             // Create price range
             $rangePrice = new \RangePrice();
             $rangePrice->id_carrier = $carrier->id;
             $rangePrice->delimiter1 = '0';
             $rangePrice->delimiter2 = '10000';
             $rangePrice->add();
             // Create weight range
             $rangeWeight = new \RangeWeight();
             $rangeWeight->id_carrier = $carrier->id;
             $rangeWeight->delimiter1 = '0';
             $rangeWeight->delimiter2 = '10000';
             $rangeWeight->add();
             // Associate carrier to all zones
             $zones = \Zone::getZones(true);
             foreach ($zones as $zone) {
                 \Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']));
                 \Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
                 \Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
             }
             copy(self::$instanceBaseDir . '/img/logo.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
             \Configuration::updateValue($carrier_key, $carrier->id);
         }
     }
     return true;
 }
开发者ID:panvagenas,项目名称:elta-courier-for-prestashop,代码行数:59,代码来源:Installer.php

示例3: installExternalCarrier

 public function installExternalCarrier($config)
 {
     $carrier = new Carrier();
     $carrier->name = $config['name'];
     $carrier->id_tax_rules_group = $config['id_tax_rules_group'];
     $carrier->active = $config['active'];
     $carrier->deleted = $config['deleted'];
     $carrier->delay = $config['delay'];
     $carrier->shipping_handling = $config['shipping_handling'];
     $carrier->range_behavior = $config['range_behavior'];
     $carrier->is_module = $config['is_module'];
     $carrier->shipping_external = $config['shipping_external'];
     $carrier->external_module_name = $config['external_module_name'];
     $carrier->need_range = $config['need_range'];
     $languages = Context::getContext()->language->getLanguages(true);
     foreach ($languages as $language) {
         if ($language['iso_code'] == 'cs') {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         } else {
             $carrier->delay[(int) $language['id_lang']] = '2 days';
         }
     }
     if ($carrier->add()) {
         $groups = Group::getGroups(true);
         foreach ($groups as $group) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
         }
         $rangePrice = new RangePrice();
         $rangePrice->id_carrier = $carrier->id;
         $rangePrice->delimiter1 = '0';
         $rangePrice->delimiter2 = '1000000';
         $rangePrice->add();
         $rangeWeight = new RangeWeight();
         $rangeWeight->id_carrier = $carrier->id;
         $rangeWeight->delimiter1 = '0';
         $rangeWeight->delimiter2 = '10000';
         $rangeWeight->add();
         $sql = 'SELECT DISTINCT id_zone FROM ' . _DB_PREFIX_ . 'country WHERE iso_code="CZ" OR iso_code="SK"';
         $zones = Db::getInstance()->executeS($sql);
         if (is_array($zones)) {
             foreach ($zones as $zone) {
                 Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']), 'INSERT');
                 Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
                 Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
             }
         }
         $this->module->copyLogo($carrier->id);
         if (Configuration::get('PS_TAX')) {
             $carrier->setTaxRulesGroup(1, true);
         }
         return (int) $carrier->id;
     }
     $this->messages[] = 'Failed to create external carrier ' . $config['name'];
     return false;
 }
开发者ID:ulozenka,项目名称:prestashop-1-5,代码行数:55,代码来源:PrestahostModuleInstall.php

示例4: installExternalCarrier

 public static function installExternalCarrier($config)
 {
     $carrier = new Carrier();
     $carrier->name = $config['name'];
     $carrier->id_tax_rules_group = $config['id_tax_rules_group'];
     $carrier->id_zone = $config['id_zone'];
     $carrier->active = $config['active'];
     $carrier->deleted = $config['deleted'];
     $carrier->delay = $config['delay'];
     $carrier->shipping_handling = $config['shipping_handling'];
     $carrier->range_behavior = $config['range_behavior'];
     $carrier->is_module = $config['is_module'];
     $carrier->shipping_external = $config['shipping_external'];
     $carrier->external_module_name = $config['external_module_name'];
     $carrier->need_range = $config['need_range'];
     $languages = Language::getLanguages(true);
     foreach ($languages as $language) {
         if ($language['iso_code'] == 'fr') {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         }
         if ($language['iso_code'] == 'en') {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         }
         if ($language['iso_code'] == Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'))) {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         }
     }
     if ($carrier->add()) {
         $groups = Group::getGroups(true);
         foreach ($groups as $group) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
         }
         $rangePrice = new RangePrice();
         $rangePrice->id_carrier = $carrier->id;
         $rangePrice->delimiter1 = '0';
         $rangePrice->delimiter2 = '10000';
         $rangePrice->add();
         $rangeWeight = new RangeWeight();
         $rangeWeight->id_carrier = $carrier->id;
         $rangeWeight->delimiter1 = '0';
         $rangeWeight->delimiter2 = '10000';
         $rangeWeight->add();
         $zones = Zone::getZones(true);
         foreach ($zones as $zone) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']), 'INSERT');
             Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
             Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
         }
         // Copy Logo
         if (!copy(dirname(__FILE__) . '/carrier.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg')) {
             return false;
         }
         // Return ID Carrier
         return (int) $carrier->id;
     }
     return false;
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:57,代码来源:fedexcarrier.php

示例5: addRanges

 protected function addRanges($carrier)
 {
     $range_price = new RangePrice();
     $range_price->id_carrier = $carrier->id;
     $range_price->delimiter1 = '0';
     $range_price->delimiter2 = '10000';
     $range_price->add();
     $range_weight = new RangeWeight();
     $range_weight->id_carrier = $carrier->id;
     $range_weight->delimiter1 = '0';
     $range_weight->delimiter2 = '10000';
     $range_weight->add();
 }
开发者ID:evgrishin,项目名称:egdelivery,代码行数:13,代码来源:egdelivery.php

示例6: installExternalCarrier

 public static function installExternalCarrier($config)
 {
     $carrier = new Carrier();
     $carrier->hydrate($config);
     $carrier->name = $config['name'];
     $carrier->id_zone = $config['id_zone'];
     $carrier->active = $config['active'];
     $carrier->deleted = $config['deleted'];
     $carrier->delay = $config['delay'];
     $carrier->shipping_handling = $config['shipping_handling'];
     $carrier->range_behavior = $config['range_behavior'];
     $carrier->is_module = $config['is_module'];
     $carrier->shipping_external = $config['shipping_external'];
     $carrier->external_module_name = $config['external_module_name'];
     $carrier->need_range = $config['need_range'];
     $carrier->setTaxRulesGroup($config['id_tax_rules_group'], true);
     $languages = Language::getLanguages(true);
     foreach ($languages as $language) {
         if ($language['iso_code'] == 'lv') {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         }
         if ($language['iso_code'] == 'lt') {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         }
         if ($language['iso_code'] == Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'))) {
             $carrier->delay[(int) $language['id_lang']] = $config['delay'][$language['iso_code']];
         }
     }
     if ($carrier->add()) {
         $groups = Group::getGroups(true);
         foreach ($groups as $group) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
         }
         // $range_price = new RangePrice();
         // $range_price->id_carrier = $carrier->id;
         // $range_price->delimiter1 = '0';
         // $range_price->delimiter2 = '10000';
         // $range_price->add();
         // $range_weight = new RangeWeight();
         // $range_weight->id_carrier = $carrier->id;
         // $range_weight->delimiter1 = '0';
         // $range_weight->delimiter2 = '10000';
         // $range_weight->add();
         // Add weight ranges to carrier
         $rangePrices = array();
         foreach ($config['ranges'] as $range) {
             $rangeWeight = new RangeWeight();
             $rangeWeight->hydrate(array('id_carrier' => $carrier->id, 'delimiter1' => (double) $range['delimiter1'], 'delimiter2' => (double) $range['delimiter2']));
             $rangeWeight->add();
             // Save range ID and price and set it after the Zones have been added
             $rangePrices[] = array('id_range_weight' => $rangeWeight->id, 'price' => $range['price']);
         }
         // Update prices in delivery table for each range (need IDs)
         foreach ($rangePrices as $rangePrice) {
             $data = array('price' => $rangePrice['price']);
             $where = 'id_range_weight = ' . $rangePrice['id_range_weight'];
             Db::getInstance()->update('delivery', $data, $where);
         }
         // Add Europe for EVERY carrier range
         // Automatically creates rows in delivery table, price is 0
         $id_zone_europe = Zone::getIdByName('Europe');
         $carrier->addZone($id_zone_europe ? $id_zone_europe : 1);
         // Copy Logo
         if (!Tools::copy(dirname(__FILE__) . '/logo.png', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.png')) {
             return false;
         }
         DpdCarrierOptions::setCarrierOptions((int) $carrier->id, (int) $carrier->id, $config['type']);
         // Return ID Carrier
         return (int) $carrier->id;
     }
     return false;
 }
开发者ID:uab-balticode,项目名称:dpd-shipping-module-prestashop-2,代码行数:72,代码来源:dynamicparceldistribution.php

示例7: createShopgateCarrier

 /**
  * create shopgate carrier
  */
 public function createShopgateCarrier()
 {
     /** @var CarrierCore $carrier */
     $carrier = new Carrier();
     $carrier->name = self::MODULE_CARRIER_NAME;
     $carrier->active = true;
     $carrier->deleted = true;
     $carrier->shipping_handling = false;
     $carrier->range_behavior = true;
     $carrier->delay[Configuration::get('PS_LANG_DEFAULT')] = self::MODULE_CARRIER_NAME;
     $carrier->shipping_external = true;
     $carrier->is_module = true;
     $carrier->external_module_name = self::DEFAULT_EXTERNAL_MODULE_CARRIER_NAME;
     $carrier->need_range = true;
     foreach (Language::getLanguages() as $language) {
         $carrier->delay[$language['id_lang']] = 'Depends on Shopgate selected carrier';
     }
     if ($carrier->add()) {
         $groups = Group::getGroups(true);
         foreach ($groups as $group) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
         }
         /** @var RangePriceCore $rangePrice */
         $rangePrice = new RangePrice();
         $rangePrice->id_carrier = $carrier->id;
         $rangePrice->delimiter1 = '0';
         $rangePrice->delimiter2 = '1000000';
         $rangePrice->add();
         /** @var RangeWeightCore $rangeWeight */
         $rangeWeight = new RangeWeight();
         $rangeWeight->id_carrier = $carrier->id;
         $rangeWeight->delimiter1 = '0';
         $rangeWeight->delimiter2 = '1000000';
         $rangeWeight->add();
         $zones = Zone::getZones(true);
         foreach ($zones as $zone) {
             /** @var $zone ZoneCore */
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']), 'INSERT');
             Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
             Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
         }
     }
     Configuration::updateValue('SG_CARRIER_ID', $carrier->id);
 }
开发者ID:pankajshoffex,项目名称:shoffex_prestashop,代码行数:47,代码来源:Shipping.php

示例8: carrierCompatibility

 private function carrierCompatibility($carrier)
 {
     // fix a bug in Prestashop before version 1.4.4.0 classes/cart.php function isCarrierInRange() range behavior
     $rangePrices = RangePrice::getRanges($carrier->id);
     if (empty($rangePrices)) {
         $rangePrice = new RangePrice();
         $rangePrice->id_carrier = $carrier->id;
         $rangePrice->delimiter1 = 0.0;
         $rangePrice->delimiter2 = 1000000.0;
         if (!$rangePrice->add()) {
             $this->log('installation adding rangePrice failed', ShopgateLogger::LOGTYPE_ACCESS);
             return false;
         }
     } else {
         $rangePrice = new RangeWeight($rangePrices[0]['id_range_price']);
     }
     $rangeWeights = RangeWeight::getRanges($carrier->id);
     if (empty($rangeWeights)) {
         $rangeWeight = new RangeWeight();
         $rangeWeight->id_carrier = $carrier->id;
         $rangeWeight->delimiter1 = 0.0;
         $rangeWeight->delimiter2 = 1000000.0;
         if (!$rangeWeight->add()) {
             $this->log('installation adding rangeWeight failed', ShopgateLogger::LOGTYPE_ACCESS);
             return false;
         }
     } else {
         $rangeWeight = new RangeWeight($rangeWeights[0]['id_range_weight']);
     }
     // Zones
     $zones = Zone::getZones();
     foreach ($zones as $zone) {
         $carrier->addZone($zone['id_zone']);
     }
     // create for each zone delivery options
     foreach ($zones as $zone) {
         $deliveryRangeWeight = new Delivery();
         $deliveryRangeWeight->id_carrier = $carrier->id;
         $deliveryRangeWeight->id_range_weight = $rangeWeight->id;
         $deliveryRangeWeight->id_range_price = 0;
         $deliveryRangeWeight->price = 0;
         $deliveryRangeWeight->id_zone = $zone['id_zone'];
         if (!$deliveryRangeWeight->add(true, true)) {
             $this->log('installation adding deliveryRangeWeight failed', ShopgateLogger::LOGTYPE_ACCESS);
             return false;
         }
         $deliveryRangePrice = new Delivery();
         $deliveryRangePrice->id_carrier = $carrier->id;
         $deliveryRangePrice->id_range_price = $rangePrice->id;
         $deliveryRangePrice->id_range_weight = 0;
         $deliveryRangePrice->price = 0;
         $deliveryRangePrice->id_zone = $zone['id_zone'];
         if (!$deliveryRangePrice->add(true, true)) {
             $this->log('installation adding deliveryRangePrice failed', ShopgateLogger::LOGTYPE_ACCESS);
             return false;
         }
     }
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:58,代码来源:shopgate.php

示例9: createCarriers

 protected function createCarriers($eta)
 {
     // Sameday(ETA: 18:00)
     foreach ($this->carriers as $key => $value) {
         //Create new carrier
         $carrier = new Carrier();
         $carrier->name = $key;
         $carrier->active = true;
         $carrier->deleted = 0;
         $carrier->shipping_handling = false;
         $carrier->range_behavior = 0;
         $carrier->delay[Configuration::get('PS_LANG_DEFAULT')] = $eta;
         $carrier->shipping_external = true;
         $carrier->is_module = true;
         $carrier->external_module_name = $this->name;
         $carrier->need_range = true;
         $carrier->url = 'https://send24.com/track?@';
         if ($carrier->add()) {
             $groups = Group::getGroups(true);
             foreach ($groups as $group) {
                 Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
             }
             $rangePrice = new RangePrice();
             $rangePrice->id_carrier = $carrier->id;
             $rangePrice->delimiter1 = '0';
             $rangePrice->delimiter2 = '5';
             $rangePrice->add();
             $rangeWeight = new RangeWeight();
             $rangeWeight->id_carrier = $carrier->id;
             $rangeWeight->delimiter1 = '0';
             $rangeWeight->delimiter2 = '5';
             $rangeWeight->add();
             $zones = Zone::getZones(true);
             foreach ($zones as $z) {
                 if ($z['name'] == 'Europe') {
                     Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $z['id_zone']), 'INSERT');
                     Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $z['id_zone'], 'price' => '0'), 'INSERT');
                     Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $z['id_zone'], 'price' => '0'), 'INSERT');
                 }
             }
             copy(dirname(__FILE__) . '/views/img/send24.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
             Configuration::updateValue(self::PREFIX . $value, $carrier->id);
             Configuration::updateValue(self::PREFIX . $value . '_reference', $carrier->id);
         }
     }
     return true;
 }
开发者ID:Send24com,项目名称:Send24-for-Prestashop,代码行数:47,代码来源:send24.php

示例10: installCarriers

 public function installCarriers()
 {
     $id_lang_default = Language::getIsoById(Configuration::get('PS_LANG_DEFAULT'));
     $carriers_list = array('MYMOD_CA_CLDE' => 'Classic delivery', 'MYMOD_CA_REPO' => 'Relay Point');
     foreach ($carriers_list as $carrier_key => $carrier_name) {
         if (Configuration::get($carrier_key) < 1) {
             // Create new carrier
             $carrier = new Carrier();
             $carrier->name = $carrier_name;
             $carrier->id_tax_rules_group = 0;
             $carrier->active = 1;
             $carrier->deleted = 0;
             foreach (Language::getLanguages(true) as $language) {
                 $carrier->delay[(int) $language['id_lang']] = 'Delay ' . $carrier_name;
             }
             $carrier->shipping_handling = false;
             $carrier->range_behavior = 0;
             $carrier->is_module = true;
             $carrier->shipping_external = true;
             $carrier->external_module_name = $this->name;
             $carrier->need_range = true;
             if (!$carrier->add()) {
                 return false;
             }
             // Associate carrier to all groups
             $groups = Group::getGroups(true);
             foreach ($groups as $group) {
                 Db::getInstance()->insert('carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']));
             }
             // Create price range
             $rangePrice = new RangePrice();
             $rangePrice->id_carrier = $carrier->id;
             $rangePrice->delimiter1 = '0';
             $rangePrice->delimiter2 = '10000';
             $rangePrice->add();
             // Create weight range
             $rangeWeight = new RangeWeight();
             $rangeWeight->id_carrier = $carrier->id;
             $rangeWeight->delimiter1 = '0';
             $rangeWeight->delimiter2 = '10000';
             $rangeWeight->add();
             // Associate carrier to all zones
             $zones = Zone::getZones(true);
             foreach ($zones as $zone) {
                 Db::getInstance()->insert('carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']));
                 Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
                 Db::getInstance()->insert('delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'));
             }
             // Copy the carrier logo
             copy(dirname(__FILE__) . '/views/img/' . $carrier_key . '.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
             // Save the carrier ID in the Configuration table
             Configuration::updateValue($carrier_key, $carrier->id);
         }
     }
     return true;
 }
开发者ID:andregugliotti,项目名称:mymodcarrier,代码行数:56,代码来源:mymodcarrier.php

示例11: createSoColissimoCarrierSeller

 public static function createSoColissimoCarrierSeller($config)
 {
     $carrier = new Carrier();
     $carrier->name = $config['name'] . ' - Commerce de proximité';
     $carrier->id_tax_rules_group = $config['id_tax_rules_group'];
     $carrier->id_zone = $config['id_zone'];
     $carrier->url = $config['url'];
     $carrier->active = 0;
     $carrier->deleted = $config['deleted'];
     $carrier->delay = $config['delay'];
     $carrier->shipping_handling = $config['shipping_handling'];
     $carrier->range_behavior = $config['range_behavior'];
     $carrier->is_module = $config['is_module'];
     $carrier->shipping_external = $config['shipping_external'];
     $carrier->external_module_name = $config['external_module_name'];
     $carrier->need_range = $config['need_range'];
     $languages = Language::getLanguages(true);
     foreach ($languages as $language) {
         if ($language['iso_code'] == 'fr') {
             $carrier->delay[$language['id_lang']] = $config['delay_seller'][$language['iso_code']];
         }
         if ($language['iso_code'] == 'en') {
             $carrier->delay[$language['id_lang']] = $config['delay_seller'][$language['iso_code']];
         }
     }
     if ($carrier->add()) {
         if (!version_compare(_PS_VERSION_, '1.5', '<')) {
             if (Shop::isFeatureActive()) {
                 Shop::setContext(Shop::CONTEXT_ALL);
             }
         }
         Configuration::updateValue('SOCOLISSIMO_CARRIER_ID_SELLER', (int) $carrier->id);
         $groups = Group::getgroups(true);
         foreach ($groups as $group) {
             Db::getInstance()->execute('INSERT INTO ' . _DB_PREFIX_ . 'carrier_group VALUE (\'' . (int) $carrier->id . '\',\'' . (int) $group['id_group'] . '\')');
         }
         $range_price = new RangePrice();
         $range_price->id_carrier = $carrier->id;
         $range_price->delimiter1 = '0';
         $range_price->delimiter2 = '10000';
         $range_price->add();
         $range_weight = new RangeWeight();
         $range_weight->id_carrier = $carrier->id;
         $range_weight->delimiter1 = '0';
         $range_weight->delimiter2 = '10000';
         $range_weight->add();
         //copy logo
         if (!copy(dirname(__FILE__) . '/img/socolissimo.jpg', _PS_SHIP_IMG_DIR_ . '/' . $carrier->id . '.jpg')) {
             return false;
         }
         return true;
     }
     return false;
 }
开发者ID:sylvaincha,项目名称:Prestashop-SoColissimo,代码行数:54,代码来源:socolissimo.php

示例12: cAddCarrierPost

 public function cAddCarrierPost()
 {
     $db = Db::getInstance();
     if (!Tools::getIsset('packetery_add_carrier') || !Tools::getValue('packetery_add_carrier')) {
         return;
     }
     $carrier = new Carrier();
     $carrier->name = Tools::getValue('packetery_carrier_name');
     $carrier->active = true;
     $carrier->shipping_method = defined('Carrier::SHIPPING_METHOD_WEIGHT') ? Carrier::SHIPPING_METHOD_WEIGHT : 1;
     $carrier->deleted = 0;
     $carrier->range_behavior = true;
     // true disables this carrier if outside weight range
     $carrier->is_module = false;
     $carrier->external_module_name = "packetery";
     $carrier->need_range = true;
     foreach (Language::getLanguages(true) as $language) {
         if (Tools::getIsset('delay_' . $language['id_lang']) && Tools::getValue('delay_' . $language['id_lang'])) {
             $carrier->delay[$language['id_lang']] = Tools::getValue('delay_' . $language['id_lang']);
         }
     }
     if (!$carrier->add()) {
         return false;
     }
     $country = "";
     $countries = Tools::getValue('packetery_carrier_country');
     foreach ($countries as $key => $countryCode) {
         $country .= $countryCode;
         if ($key != count($countries) - 1) {
             $country .= ',';
         }
     }
     $db->execute('insert into `' . _DB_PREFIX_ . 'packetery_carrier` set id_carrier=' . (int) $carrier->id . ', country="' . pSQL($country ? $country : 'cz,sk') . '", list_type=' . (int) Tools::getValue('packetery_carrier_list_type') . ', is_cod=' . (Tools::getIsset('packetery_carrier_is_cod') ? (int) Tools::getValue('packetery_carrier_is_cod') : 0));
     foreach (Group::getGroups(true) as $group) {
         $db->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
     }
     $rangeWeight = new RangeWeight();
     $rangeWeight->id_carrier = $carrier->id;
     $rangeWeight->delimiter1 = '0';
     $rangeWeight->delimiter2 = '5';
     $rangeWeight->add();
     $rangePrice = new RangePrice();
     $rangePrice->id_carrier = $carrier->id;
     $rangePrice->delimiter1 = '0';
     $rangePrice->delimiter2 = '1000000';
     $rangePrice->add();
     $zones = Zone::getZones(true);
     foreach ($zones as $zone) {
         $db->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']), 'INSERT');
         $db->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => null, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
         $db->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => null, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
     }
     if (Tools::getIsset('packetery_carrier_logo') && Tools::strlen(Tools::getValue('packetery_carrier_logo')) == 2) {
         copy(dirname(__FILE__) . '/logo-' . Tools::getValue('packetery_carrier_logo') . '.jpg', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg');
     }
 }
开发者ID:Naxmars,项目名称:prestashop,代码行数:56,代码来源:packetery.php

示例13: createCarrier

 private function createCarrier($config, $product_id, $name, $debug_mode = false, &$debug_info = array())
 {
     $carrier = new Carrier();
     if ($debug_mode) {
         array_push($debug_info, "Trying to create carrier " . $product_id . " with name " . $name);
     }
     $carrier->name = $name;
     $carrier->id_zone = $config['id_zone'];
     $carrier->url = $config['url'];
     $carrier->active = $config['active'];
     $carrier->deleted = $config['deleted'];
     $carrier->shipping_handling = $config['shipping_handling'];
     $carrier->range_behaviour = $config['range_behaviour'];
     $carrier->is_module = $config['is_module'];
     $carrier->shipping_external = $config['shipping_external'];
     $carrier->external_module_name = $config['external_module_name'];
     $carrier->need_range = $config['need_range'];
     $languages = Language::getLanguages(true);
     foreach ($languages as $language) {
         if ($language['iso_code'] == 'en') {
             $carrier->delay[$language['id_lang']] = $config['delay'][$language['iso_code']];
         }
         if ($language['iso_code'] == 'no') {
             $carrier->delay[$language['id_lang']] = $config['delay'][$language['iso_code']];
         }
     }
     if ($debug_mode) {
         array_push($debug_info, "Adding carrier");
     }
     if ($carrier->add()) {
         if ($debug_mode) {
             array_push($debug_info, "Carrier added, setting up associations");
         }
         $carriers_str = Configuration::get('FRAKTGUIDE_CREATED_CARRIER_IDS');
         $carriers = $carriers_str ? explode(';', Configuration::get('FRAKTGUIDE_CREATED_CARRIER_IDS')) : array();
         $carriers[] = $carrier->id;
         Configuration::updateValue('FRAKTGUIDE_CREATED_CARRIER_IDS', implode(';', $carriers));
         $zones = Zone::getZones(true);
         foreach ($zones as $zone) {
             Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'carrier_zone VALUE(\'' . (int) $carrier->id . '\', \'' . (int) $zone['id_zone'] . '\')');
         }
         $groups = Group::getgroups(true);
         foreach ($groups as $group) {
             Db::getInstance()->execute('INSERT INTO ' . _DB_PREFIX_ . 'carrier_group VALUE (\'' . (int) $carrier->id . '\',\'' . (int) $group['id_group'] . '\')');
         }
         $rangePrice = new RangePrice();
         $rangePrice->id_carrier = $carrier->id;
         $rangePrice->delimiter1 = '0';
         $rangePrice->delimiter2 = '10000';
         $rangePrice->add();
         $rangeWeight = new RangeWeight();
         $rangeWeight->id_carrier = $carrier->id;
         $rangeWeight->delimiter1 = '0';
         $rangeWeight->delimiter2 = '10000';
         $rangeWeight->add();
         if ($debug_mode) {
             array_push($debug_info, "Trying to update product name table");
         }
         if (!Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'fraktguide_product_names`(`id_carrier`, `product_id`) VALUES(' . $carrier->id . ', \'' . $product_id . '\')')) {
             return false;
         }
         if (!copy(dirname(__FILE__) . '/img/logo.png', _PS_SHIP_IMG_DIR_ . '/' . $carrier->id . '.jpg')) {
             return false;
         }
         if ($debug_mode) {
             array_push($debug_info, "Success");
         }
         // Link to correct tax group (ps_carrier_tax_rules_group_shop aparently...)
         if (!Db::getInstance()->insert('carrier_tax_rules_group_shop', array('id_carrier' => $carrier->id, 'id_tax_rules_group' => Configuration::get('FRAKTGUIDE_ID_TAX_RULES_GROUP'), 'id_shop' => Context::getContext()->shop->id))) {
             return false;
         }
         return true;
     } else {
         Tools::dieOrLog("Error creating carrier " . $product_id);
         return false;
     }
 }
开发者ID:nilsga,项目名称:prestashop-fraktguide,代码行数:77,代码来源:fraktguide.php

示例14: createChronopostCarriers

 public static function createChronopostCarriers($carrierConfig)
 {
     if (Shop::isFeatureActive()) {
         Shop::setContext(Shop::CONTEXT_ALL);
     }
     // Create carriers from config
     foreach ($carrierConfig as $carrierName => $config) {
         $carrier = new Carrier();
         $carrier->name = $config['name'];
         $carrier->id_tax_rules_group = $config['id_tax_rules_group'];
         $carrier->url = $config['url'];
         $carrier->active = $config['active'];
         $carrier->deleted = $config['deleted'];
         $carrier->delay = $config['delay'];
         $carrier->shipping_handling = $config['shipping_handling'];
         $carrier->range_behavior = $config['range_behavior'];
         $carrier->is_module = $config['is_module'];
         $carrier->shipping_external = $config['shipping_external'];
         $carrier->external_module_name = $config['external_module_name'];
         $carrier->need_range = $config['need_range'];
         $languages = Language::getLanguages(true);
         foreach ($languages as $language) {
             if (array_key_exists($language['iso_code'], $config['delay'])) {
                 $carrier->delay[$language['id_lang']] = $config['delay'][$language['iso_code']];
             } else {
                 $carrier->delay[$language['id_lang']] = $config['delay']['fr'];
             }
         }
         if ($carrier->add()) {
             Configuration::updateValue($config['configuration_item'], (int) $carrier->id);
             // ASSIGN GROUPS
             $groups = Group::getgroups(true);
             foreach ($groups as $group) {
                 Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'carrier_group VALUE (\'' . (int) $carrier->id . '\',\'' . (int) $group['id_group'] . '\')');
             }
             // ASSIGN ZONES
             $zones = Zone::getZones();
             foreach ($zones as $zone) {
                 $carrier->addZone($zone['id_zone']);
             }
             // RANGE PRICE
             $rp = new RangePrice();
             $rp->id_carrier = $carrier->id;
             $rp->delimiter1 = 0;
             $rp->delimiter2 = 100000;
             $rp->add();
             $fp = fopen(_MYDIR_ . '/csv/' . $carrierName . '.csv', 'r');
             // insert prices per weight range
             while ($line = fgetcsv($fp)) {
                 $rangeWeight = new RangeWeight();
                 $rangeWeight->id_carrier = $carrier->id;
                 $rangeWeight->delimiter1 = $line[0];
                 $rangeWeight->delimiter2 = $line[1];
                 $rangeWeight->price_to_affect = $line[2];
                 $rangeWeight->add();
             }
             //copy logo
             if (!copy(dirname(__FILE__) . '/views/img/' . $config['logo_filename'] . '.jpg', _PS_SHIP_IMG_DIR_ . '/' . $carrier->id . '.jpg')) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:rcollard,项目名称:chronopost,代码行数:64,代码来源:chronopost.php

示例15: installExternalCarrier

 /**
  * 
  * @param type $config
  * @return boolean
  */
 public function installExternalCarrier($config)
 {
     $check = Db::getInstance()->executeS("SELECT id_carrier FROM " . _DB_PREFIX_ . "carrier WHERE name = '" . $config['name'] . "' ");
     if (is_array($check) && !empty($check)) {
         return Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier', array('deleted' => 0), 'UPDATE', ' name = "' . $config['name'] . '" ');
     }
     $carrier = new Carrier();
     $carrier->name = $config['name'];
     $carrier->url = $config['url'];
     $carrier->id_tax_rules_group = $config['id_tax_rules_group'];
     $carrier->id_zone = $config['id_zone'];
     $carrier->active = $config['active'];
     $carrier->deleted = $config['deleted'];
     $carrier->delay = $config['delay'];
     $carrier->shipping_handling = $config['shipping_handling'];
     $carrier->range_behavior = $config['range_behavior'];
     $carrier->is_module = $config['is_module'];
     $carrier->shipping_external = $config['shipping_external'];
     $carrier->external_module_name = $config['external_module_name'];
     $carrier->need_range = $config['need_range'];
     $languages = Language::getLanguages(true);
     foreach ($languages as $language) {
         $carrier->delay[(int) $language['id_lang']] = $config['delay']['br'];
     }
     if ($carrier->add()) {
         $groups = Group::getGroups(true);
         foreach ($groups as $group) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_group', array('id_carrier' => (int) $carrier->id, 'id_group' => (int) $group['id_group']), 'INSERT');
         }
         $rangePrice = new RangePrice();
         $rangePrice->id_carrier = $carrier->id;
         $rangePrice->delimiter1 = '0';
         $rangePrice->delimiter2 = '0';
         $rangePrice->add();
         $rangeWeight = new RangeWeight();
         $rangeWeight->id_carrier = $carrier->id;
         $rangeWeight->delimiter1 = '0';
         $rangeWeight->delimiter2 = '30';
         $rangeWeight->add();
         $zones = Zone::getZones(true);
         foreach ($zones as $zone) {
             Db::getInstance()->autoExecute(_DB_PREFIX_ . 'carrier_zone', array('id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone']), 'INSERT');
             Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => (int) $rangePrice->id, 'id_range_weight' => NULL, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
             Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_ . 'delivery', array('id_carrier' => (int) $carrier->id, 'id_range_price' => NULL, 'id_range_weight' => (int) $rangeWeight->id, 'id_zone' => (int) $zone['id_zone'], 'price' => '0'), 'INSERT');
         }
         Configuration::updateValue("PS_CORREIOS_CARRIER_{$carrier->id}", $config['cod_servico']);
         // Copy Logo
         if (!copy(dirname(__FILE__) . '/logos/' . $config['cod_servico'] . '.png', _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg')) {
             return false;
         }
         // Return ID Carrier
         return (int) $carrier->id;
     }
     return false;
 }
开发者ID:dlanileonardo,项目名称:correios,代码行数:60,代码来源:correios.php


注:本文中的RangeWeight::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。