本文整理汇总了PHP中RangeWeight::save方法的典型用法代码示例。如果您正苦于以下问题:PHP RangeWeight::save方法的具体用法?PHP RangeWeight::save怎么用?PHP RangeWeight::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RangeWeight
的用法示例。
在下文中一共展示了RangeWeight::save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: createDefaultRanges
private static function createDefaultRanges()
{
$ids_ranges_seur = array();
$ids_ranges_pos = array();
$ids_ranges_canarias_48 = array();
$ids_ranges_canarias_m = array();
if (self::$carrier_seur->id != self::$carrier_pos->id && self::$carrier_seur->id != self::$carrier_canarias_48->id && self::$carrier_seur->id != self::$carrier_canarias_m->id) {
foreach (self::$ranges as $from => $to) {
$range_seur = new RangeWeight();
$range_seur->id_carrier = self::$carrier_seur->id;
$range_seur->delimiter1 = $from;
$range_seur->delimiter2 = $to;
$range_seur->save();
$ids_ranges_seur[$from] = $range_seur->id;
}
}
if (self::$carrier_pos->id != self::$carrier_seur->id && self::$carrier_pos->id != self::$carrier_canarias_48->id && self::$carrier_pos->id != self::$carrier_canarias_m->id) {
foreach (self::$ranges as $from => $to) {
$range_pos = new RangeWeight();
$range_pos->id_carrier = self::$carrier_pos->id;
$range_pos->delimiter1 = $from;
$range_pos->delimiter2 = $to;
$range_pos->save();
$ids_ranges_pos[$from] = $range_pos->id;
}
}
if (self::$carrier_canarias_48->id != self::$carrier_seur->id && self::$carrier_canarias_48->id != self::$carrier_pos->id && self::$carrier_canarias_48->id != self::$carrier_canarias_m->id) {
foreach (self::$ranges as $from => $to) {
$range_canarias_48 = new RangeWeight();
$range_canarias_48->id_carrier = self::$carrier_canarias_48->id;
$range_canarias_48->delimiter1 = $from;
$range_canarias_48->delimiter2 = $to;
$range_canarias_48->save();
$ids_ranges_canarias_48[$from] = $range_canarias_48->id;
}
}
if (self::$carrier_canarias_m->id != self::$carrier_seur->id && self::$carrier_canarias_m->id != self::$carrier_pos->id && self::$carrier_canarias_m->id != self::$carrier_canarias_48->id) {
foreach (self::$ranges as $from => $to) {
$range_canarias_m = new RangeWeight();
$range_canarias_m->id_carrier = self::$carrier_canarias_m->id;
$range_canarias_m->delimiter1 = $from;
$range_canarias_m->delimiter2 = $to;
$range_canarias_m->save();
$ids_ranges_canarias_m[$from] = $range_canarias_m->id;
}
}
$range_table_seur = self::$carrier_seur->getRangeTable();
$range_table_pos = self::$carrier_pos->getRangeTable();
$range_table_48 = self::$carrier_canarias_48->getRangeTable();
$range_table_m = self::$carrier_canarias_m->getRangeTable();
self::$carrier_seur->deleteDeliveryPrice($range_table_seur);
self::$carrier_pos->deleteDeliveryPrice($range_table_pos);
self::$carrier_canarias_48->deleteDeliveryPrice($range_table_48);
self::$carrier_canarias_m->deleteDeliveryPrice($range_table_m);
if (version_compare(_PS_VERSION_, '1.5', '>=')) {
$priceListSeur = array();
$priceListPos = array();
$priceListC_48 = array();
$priceListSeurC_M = array();
foreach (self::$ranges as $from => $to) {
/*
* carrier_seur
*/
$priceListSeur[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_seur->id, 'id_zone' => (int) self::$provincia->id, 'price' => 0);
$priceListSeur[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_seur->id, 'id_zone' => (int) self::$peninsula->id, 'price' => 0);
$priceListSeur[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_seur->id, 'id_zone' => (int) self::$portugal->id, 'price' => 0);
$priceListSeur[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_seur->id, 'id_zone' => (int) self::$baleares->id, 'price' => 0);
$priceListSeur[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_seur->id, 'id_zone' => (int) self::$ceuta_melilla->id, 'price' => 0);
/*
* carrier_pos
*/
if (self::$carrier_seur->id != self::$carrier_pos->id) {
$priceListPos[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_pos->id, 'id_zone' => (int) self::$provincia->id, 'price' => 0);
$priceListPos[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_pos->id, 'id_zone' => (int) self::$peninsula->id, 'price' => 0);
$priceListPos[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_pos->id, 'id_zone' => (int) self::$portugal->id, 'price' => 0);
$priceListPos[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_pos->id, 'id_zone' => (int) self::$baleares->id, 'price' => 0);
$priceListPos[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_pos->id, 'id_zone' => (int) self::$ceuta_melilla->id, 'price' => 0);
}
/*
* carrier_canarias_48
*/
$priceListC_48[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_canarias_48->id, 'id_zone' => (int) self::$canarias->id, 'price' => 0);
/*
* carrier_canarias_m
*/
if (self::$carrier_canarias_48->id != self::$carrier_canarias_m->id) {
$priceListSeurC_M[] = array('id_range_price' => 'NULL', 'id_range_weight' => (int) $ids_ranges_seur[$from], 'id_carrier' => (int) self::$carrier_canarias_m->id, 'id_zone' => (int) self::$canarias->id, 'price' => 0);
}
}
self::$carrier_seur->addDeliveryPrice($priceListSeur);
if (self::$carrier_seur->id != self::$carrier_pos->id) {
self::$carrier_pos->addDeliveryPrice($priceListPos);
}
self::$carrier_canarias_48->addDeliveryPrice($priceListC_48);
if (self::$carrier_canarias_48->id != self::$carrier_canarias_m->id) {
self::$carrier_canarias_m->addDeliveryPrice($priceListSeurC_M);
}
} else {
foreach (self::$ranges as $from => $to) {
/*
//.........这里部分代码省略.........