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


PHP Carrier::setGroups方法代码示例

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


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

示例1: createCarriers

 private function createCarriers()
 {
     $history_table = SeurLib::getLastSeurCarriers();
     if (empty($history_table) == false) {
         return $this->updateCarriers($history_table);
     }
     $carriers = array(array('name' => 'SEUR', 'active' => 1, 'type' => 'SEN', 'delay' => array('es' => 'Envío Urgente', 'fr' => 'Livraison Express', 'default' => 'Express Delivery')), array('name' => 'SEUR Puntos de Venta', 'active' => 0, 'type' => 'SEP', 'delay' => array('es' => 'Recogida en punto de venta', 'fr' => 'Retrait au point de venta', 'default' => 'Point of sale pickup')), array('name' => 'SEUR Canarias (M)', 'active' => 1, 'type' => 'SCN', 'delay' => array('es' => 'Envío a Islas Canarias', 'fr' => 'Livraison a Canary Islands', 'default' => 'Delivery to Canary Islands')), array('name' => 'SEUR Canarias (48/72)', 'active' => 1, 'type' => 'SCE', 'delay' => array('es' => 'Envío Urgente a Islas Canarias', 'fr' => 'Livraison Express a Canary Islands', 'default' => 'Express Delivery to Canary Islands')));
     foreach ($carriers as &$values) {
         $carrier = new Carrier();
         $carrier->name = $values['name'];
         $carrier->id_tax_rules_group = 1;
         $carrier->need_range = true;
         $carrier->is_module = true;
         $carrier->external_module_name = $this->name;
         $carrier->url = 'http://www.seur.com';
         $carrier->active = $values['active'];
         $languages = Language::getLanguages();
         foreach ($languages as $language) {
             if (isset($values['delay'][$language['iso_code']])) {
                 $carrier->delay[(int) $language['id_lang']] = $values['delay'][$language['iso_code']];
             } else {
                 $carrier->delay[(int) $language['id_lang']] = $values['delay']['default'];
             }
         }
         if ($carrier->save() == false) {
             return false;
         }
         $values['id'] = (int) $carrier->id;
         @copy(dirname(__FILE__) . '/img/logoSEUR.jpg', _PS_SHIP_IMG_DIR_ . (int) $carrier->id . '.jpg');
         $groups = array();
         foreach (Group::getGroups((int) Context::getContext()->language->id) as $group) {
             $groups[] = (int) $group['id_group'];
         }
         if (version_compare(_PS_VERSION_, '1.5', '<')) {
             if (!$this->setGroups14((int) $carrier->id, $groups)) {
                 return false;
             }
         } else {
             if (!$carrier->setGroups($groups)) {
                 return false;
             }
         }
     }
     SeurLib::updateSeurCarriers($carriers);
     return true;
 }
开发者ID:tomideru,项目名称:PrestaShop-modules,代码行数:46,代码来源:seur.php

示例2: install

 public static function install($carrier_type, $carrier_name)
 {
     $id_carrier = (int) Configuration::get($carrier_type);
     if (version_compare(_PS_VERSION_, '1.5', '<')) {
         $id_carrier = (int) DpdGroupCarrier::getIdCarrierByReference((int) $id_carrier);
         $carrier = new Carrier((int) $id_carrier);
     } else {
         $carrier = Carrier::getCarrierByReference($id_carrier);
     }
     if ($id_carrier && Validate::isLoadedObject($carrier)) {
         if (!$carrier->deleted) {
             return true;
         } else {
             $carrier->deleted = 0;
             return (bool) $carrier->save();
         }
     }
     $service = new DpdGroupService();
     $carrier = new Carrier();
     $carrier->name = $carrier_name;
     $carrier->active = 1;
     $carrier->is_free = 0;
     $carrier->shipping_handling = 1;
     $carrier->shipping_external = 1;
     $carrier->shipping_method = 1;
     $carrier->max_width = 0;
     $carrier->max_height = 0;
     $carrier->max_weight = 0;
     $carrier->grade = 0;
     $carrier->is_module = 1;
     $carrier->need_range = 1;
     $carrier->range_behavior = 1;
     $carrier->external_module_name = $service->module_instance->name;
     $carrier->url = _DPDGROUP_TRACKING_URL_;
     $delay = array();
     foreach (Language::getLanguages(false) as $language) {
         $delay[$language['id_lang']] = $carrier_name;
     }
     $carrier->delay = $delay;
     if (!$carrier->save()) {
         return false;
     }
     $dpdgroup_carrier = new DpdGroupCarrier();
     $dpdgroup_carrier->id_carrier = (int) $carrier->id;
     $dpdgroup_carrier->id_reference = (int) $carrier->id;
     if (!$dpdgroup_carrier->save()) {
         return false;
     }
     foreach ($service->continents as $continent => $value) {
         if ($value && !$carrier->addZone($continent)) {
             return false;
         }
     }
     $groups = array();
     foreach (Group::getGroups((int) Context::getContext()->language->id) as $group) {
         $groups[] = $group['id_group'];
     }
     if (version_compare(_PS_VERSION_, '1.5.5', '<')) {
         if (!self::setGroups14((int) $carrier->id, $groups)) {
             return false;
         }
     } else {
         if (!$carrier->setGroups($groups)) {
             return false;
         }
     }
     if (!Configuration::updateValue($carrier_type, (int) $carrier->id)) {
         return false;
     }
     return true;
 }
开发者ID:remixaz,项目名称:dpdgroup,代码行数:71,代码来源:Service.php


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