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


PHP Carrier::setTaxRulesGroup方法代码示例

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


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

示例1: 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

示例2: 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


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