本文整理汇总了PHP中RangePrice::rangeExist方法的典型用法代码示例。如果您正苦于以下问题:PHP RangePrice::rangeExist方法的具体用法?PHP RangePrice::rangeExist怎么用?PHP RangePrice::rangeExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RangePrice
的用法示例。
在下文中一共展示了RangePrice::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 && RangePrice::rangeExist((int) Tools::getValue('id_carrier'), (double) Tools::getValue('delimiter1'), (double) Tools::getValue('delimiter2'))) {
$this->errors[] = Tools::displayError('The range already exists');
} elseif (RangePrice::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();
}
}
示例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;
}