本文整理汇总了PHP中RangePrice::getRanges方法的典型用法代码示例。如果您正苦于以下问题:PHP RangePrice::getRanges方法的具体用法?PHP RangePrice::getRanges怎么用?PHP RangePrice::getRanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RangePrice
的用法示例。
在下文中一共展示了RangePrice::getRanges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
public function postProcess()
{
if (isset($_POST['submitAdd' . $this->table])) {
$delimiter1 = Tools::getValue('delimiter1');
$delimiter2 = Tools::getValue('delimiter2');
if ($delimiter1 >= $delimiter2) {
$this->_errors[] = Tools::displayError('Invalid range, "From" must be lower than "To"');
}
/* Check that a similar range does not exist yet for this carrier */
if (!Tools::isSubmit('id_range_price') && !count($this->_errors) && ($ranges = RangePrice::getRanges((int) Tools::getValue('id_carrier')))) {
foreach ($ranges as $range) {
if (!($delimiter2 <= $range['delimiter1'] || $delimiter1 >= $range['delimiter2'])) {
$this->_errors[] = Tools::displayError('Invalid range, this range is overlapping an existing range');
break;
}
}
}
}
parent::postProcess();
}
示例2: addZone
/**
* Add zone
*/
public function addZone($id_zone)
{
if (Db::getInstance()->execute('
INSERT INTO `' . _DB_PREFIX_ . 'carrier_zone` (`id_carrier` , `id_zone`)
VALUES (' . (int) $this->id . ', ' . (int) $id_zone . ')
')) {
// Get all ranges for this carrier
$ranges_price = RangePrice::getRanges($this->id);
$ranges_weight = RangeWeight::getRanges($this->id);
// Create row in ps_delivery table
if (count($ranges_price) || count($ranges_weight)) {
$sql = 'INSERT INTO `' . _DB_PREFIX_ . 'delivery` (`id_carrier`, `id_range_price`, `id_range_weight`, `id_zone`, `price`) VALUES ';
if (count($ranges_price)) {
foreach ($ranges_price as $range) {
$sql .= '(' . (int) $this->id . ', ' . (int) $range['id_range_price'] . ', 0, ' . (int) $id_zone . ', 0),';
}
}
if (count($ranges_weight)) {
foreach ($ranges_weight as $range) {
$sql .= '(' . (int) $this->id . ', 0, ' . (int) $range['id_range_weight'] . ', ' . (int) $id_zone . ', 0),';
}
}
$sql = rtrim($sql, ',');
return Db::getInstance()->execute($sql);
}
return true;
}
return false;
}
示例3: carrierCompatibility
private function carrierCompatibility($carrier)
{
// fix a bug in Prestashop before version 1.4.4.0 classes/cart.php function isCarrierInRange() range behavior
$rangePrices = RangePrice::getRanges($carrier->id);
if (empty($rangePrices)) {
$rangePrice = new RangePrice();
$rangePrice->id_carrier = $carrier->id;
$rangePrice->delimiter1 = 0.0;
$rangePrice->delimiter2 = 1000000.0;
if (!$rangePrice->add()) {
$this->log('installation adding rangePrice failed', ShopgateLogger::LOGTYPE_ACCESS);
return false;
}
} else {
$rangePrice = new RangeWeight($rangePrices[0]['id_range_price']);
}
$rangeWeights = RangeWeight::getRanges($carrier->id);
if (empty($rangeWeights)) {
$rangeWeight = new RangeWeight();
$rangeWeight->id_carrier = $carrier->id;
$rangeWeight->delimiter1 = 0.0;
$rangeWeight->delimiter2 = 1000000.0;
if (!$rangeWeight->add()) {
$this->log('installation adding rangeWeight failed', ShopgateLogger::LOGTYPE_ACCESS);
return false;
}
} else {
$rangeWeight = new RangeWeight($rangeWeights[0]['id_range_weight']);
}
// Zones
$zones = Zone::getZones();
foreach ($zones as $zone) {
$carrier->addZone($zone['id_zone']);
}
// create for each zone delivery options
foreach ($zones as $zone) {
$deliveryRangeWeight = new Delivery();
$deliveryRangeWeight->id_carrier = $carrier->id;
$deliveryRangeWeight->id_range_weight = $rangeWeight->id;
$deliveryRangeWeight->id_range_price = 0;
$deliveryRangeWeight->price = 0;
$deliveryRangeWeight->id_zone = $zone['id_zone'];
if (!$deliveryRangeWeight->add(true, true)) {
$this->log('installation adding deliveryRangeWeight failed', ShopgateLogger::LOGTYPE_ACCESS);
return false;
}
$deliveryRangePrice = new Delivery();
$deliveryRangePrice->id_carrier = $carrier->id;
$deliveryRangePrice->id_range_price = $rangePrice->id;
$deliveryRangePrice->id_range_weight = 0;
$deliveryRangePrice->price = 0;
$deliveryRangePrice->id_zone = $zone['id_zone'];
if (!$deliveryRangePrice->add(true, true)) {
$this->log('installation adding deliveryRangePrice failed', ShopgateLogger::LOGTYPE_ACCESS);
return false;
}
}
}