本文整理汇总了PHP中Carrier::addDeliveryPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Carrier::addDeliveryPrice方法的具体用法?PHP Carrier::addDeliveryPrice怎么用?PHP Carrier::addDeliveryPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carrier
的用法示例。
在下文中一共展示了Carrier::addDeliveryPrice方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDejalaCarrier
/**
* creates of a dejala carrier corresponding to $dejalaProduct
*/
public static function createDejalaCarrier($dejalaConfig, $dejalaProduct)
{
// MFR091130 - get id zone from the country used in the module (if the store zones were customized) - default is 1 (Europe)
$id_zone = 1;
$moduleCountryIsoCode = strtoupper($dejalaConfig->country);
$countryID = Country::getByIso($moduleCountryIsoCode);
if (intval($countryID)) {
$id_zone = Country::getIdZone($countryID);
}
$vatRate = floatval($dejalaProduct['vat']);
// MFR091130 - get or create the tax & attach it to our zone if needed
$id_tax = Tax::getTaxIdByRate($vatRate);
if (!$id_tax) {
$tax = new Tax();
$tax->rate = $vatRate;
$defaultLanguage = Configuration::get('PS_LANG_DEFAULT');
$tax->name[$defaultLanguage] = $tax->rate . '%';
$tax->add();
$id_tax = Tax::getTaxIdByRate($vatRate);
}
if (!Tax::zoneHasTax($id_tax, $id_zone)) {
// MFR : direct call because $tax->addZone($id_zone) causes errors when called
Db::getInstance()->Execute('INSERT INTO `' . _DB_PREFIX_ . 'tax_zone` (`id_tax` , `id_zone`) VALUES (' . intval($id_tax) . ', ' . intval($id_zone) . ')');
}
$carrier = new Carrier();
$carrier->name = 'dejala';
$carrier->id_tax = $id_tax;
$carrier->url = 'http://tracking.dejala.' . $dejalaConfig->country . '/tracker/@';
$carrier->active = true;
$carrier->deleted = 0;
$carrier->shipping_handling = false;
$carrier->range_behavior = 0;
$carrier->is_module = 1;
$languages = Language::getLanguages(true);
foreach ($languages as $language) {
if ($language['iso_code'] == 'fr') {
$carrier->delay[$language['id_lang']] = utf8_encode('Quand vous voulez... Par coursier, ' . $dejalaProduct['timelimit'] . 'H');
}
if ($language['iso_code'] == 'en') {
$carrier->delay[$language['id_lang']] = utf8_encode('When you want... Dispatch rider, ' . $dejalaProduct['timelimit'] . 'H range');
}
if ($language['iso_code'] == 'es') {
$carrier->delay[$language['id_lang']] = utf8_encode('Cuando quiera... Por mensajero, ' . $dejalaProduct['timelimit'] . 'H');
}
}
$carrier->add();
$sql = 'INSERT INTO `' . _DB_PREFIX_ . 'carrier_zone` (`id_carrier` , `id_zone`) VALUES (' . intval($carrier->id) . ', ' . intval($id_zone) . ')';
Db::getInstance()->Execute($sql);
$rangeW = new RangeWeight();
$rangeW->id_carrier = $carrier->id;
$rangeW->delimiter1 = 0;
$rangeW->delimiter2 = $dejalaProduct['max_weight'];
$rangeW->add();
$vat_factor = 1 + $dejalaProduct['vat'] / 100;
$priceTTC = round($dejalaProduct['price'] * $vat_factor + $dejalaProduct['margin'], 2);
$priceHT = round($priceTTC / $vat_factor, 2);
$priceList = '(NULL' . ',' . $rangeW->id . ',' . $carrier->id . ',' . $id_zone . ',' . $priceHT . ')';
$carrier->addDeliveryPrice($priceList);
return new Carrier($carrier->id);
}
示例2: add
/**
* Override add to create delivery value for all zones
* @see classes/ObjectModelCore::add()
*
* @param bool $null_values
* @param bool $autodate
* @return bool Insertion result
*/
public function add($autodate = true, $null_values = false)
{
if (!parent::add($autodate, $null_values) || !Validate::isLoadedObject($this)) {
return false;
}
$carrier = new Carrier((int) $this->id_carrier);
$price_list = array();
foreach ($carrier->getZones() as $zone) {
$price_list[] = array('id_range_price' => (int) $this->id, 'id_range_weight' => 0, 'id_carrier' => (int) $this->id_carrier, 'id_zone' => (int) $zone['id_zone'], 'price' => 0);
}
$carrier->addDeliveryPrice($price_list);
return true;
}