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


PHP RangeWeight::rangeExist方法代码示例

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


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

示例1: postProcess

 public function postProcess()
 {
     $id = (int) Tools::getValue('id_' . $this->table);
     if (Tools::getValue('submitAdd' . $this->table)) {
         if (Tools::getValue('delimiter1') >= Tools::getValue('delimiter2')) {
             $this->errors[] = Tools::displayError('Invalid range');
         } elseif (!$id && RangeWeight::rangeExist((int) Tools::getValue('id_carrier'), (double) Tools::getValue('delimiter1'), (double) Tools::getValue('delimiter2'))) {
             $this->errors[] = Tools::displayError('The range already exists');
         } elseif (RangeWeight::isOverlapping((int) Tools::getValue('id_carrier'), (double) Tools::getValue('delimiter1'), (double) Tools::getValue('delimiter2'), $id ? (int) $id : null)) {
             $this->errors[] = Tools::displayError('Error: Ranges are overlapping');
         } elseif (!count($this->errors)) {
             parent::postProcess();
         }
     } else {
         parent::postProcess();
     }
 }
开发者ID:jpodracky,项目名称:dogs,代码行数:17,代码来源:AdminRangeWeightController.php

示例2: processRanges

 public function processRanges($id_carrier)
 {
     if (!$this->access('edit') || !$this->access('add')) {
         $this->errors[] = $this->trans('You do not have permission to use this wizard.', array(), 'Admin.Shipping.Notification');
         return;
     }
     $carrier = new Carrier((int) $id_carrier);
     if (!Validate::isLoadedObject($carrier)) {
         return false;
     }
     $range_inf = Tools::getValue('range_inf');
     $range_sup = Tools::getValue('range_sup');
     $range_type = Tools::getValue('shipping_method');
     $fees = Tools::getValue('fees');
     $carrier->deleteDeliveryPrice($carrier->getRangeTable());
     if ($range_type != Carrier::SHIPPING_METHOD_FREE) {
         foreach ($range_inf as $key => $delimiter1) {
             if (!isset($range_sup[$key])) {
                 continue;
             }
             $add_range = true;
             if ($range_type == Carrier::SHIPPING_METHOD_WEIGHT) {
                 if (!RangeWeight::rangeExist(null, (double) $delimiter1, (double) $range_sup[$key], $carrier->id_reference)) {
                     $range = new RangeWeight();
                 } else {
                     $range = new RangeWeight((int) $key);
                     $range->id_carrier = (int) $carrier->id;
                     $range->save();
                     $add_range = false;
                 }
             }
             if ($range_type == Carrier::SHIPPING_METHOD_PRICE) {
                 if (!RangePrice::rangeExist(null, (double) $delimiter1, (double) $range_sup[$key], $carrier->id_reference)) {
                     $range = new RangePrice();
                 } else {
                     $range = new RangePrice((int) $key);
                     $range->id_carrier = (int) $carrier->id;
                     $range->save();
                     $add_range = false;
                 }
             }
             if ($add_range) {
                 $range->id_carrier = (int) $carrier->id;
                 $range->delimiter1 = (double) $delimiter1;
                 $range->delimiter2 = (double) $range_sup[$key];
                 $range->save();
             }
             if (!Validate::isLoadedObject($range)) {
                 return false;
             }
             $price_list = array();
             if (is_array($fees) && count($fees)) {
                 foreach ($fees as $id_zone => $fee) {
                     $price_list[] = array('id_range_price' => $range_type == Carrier::SHIPPING_METHOD_PRICE ? (int) $range->id : null, 'id_range_weight' => $range_type == Carrier::SHIPPING_METHOD_WEIGHT ? (int) $range->id : null, 'id_carrier' => (int) $carrier->id, 'id_zone' => (int) $id_zone, 'price' => isset($fee[$key]) ? (double) str_replace(',', '.', $fee[$key]) : 0);
                 }
             }
             if (count($price_list) && !$carrier->addDeliveryPrice($price_list, true)) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:63,代码来源:AdminCarrierWizardController.php


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