本文整理汇总了PHP中Carrier::getRangeObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Carrier::getRangeObject方法的具体用法?PHP Carrier::getRangeObject怎么用?PHP Carrier::getRangeObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Carrier
的用法示例。
在下文中一共展示了Carrier::getRangeObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initContent
public function initContent()
{
$array_carrier = array();
$carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
foreach ($carriers as $key => $carrier) {
if ($carrier['is_free']) {
unset($carriers[$key]);
} else {
$array_carrier[] = $carrier['id_carrier'];
}
}
$id_carrier = (int) Tools::getValue('id_carrier');
if (count($carriers) && isset($array_carrier[0])) {
if (!$id_carrier) {
$id_carrier = (int) $array_carrier[0];
}
$carrierSelected = new Carrier((int) $id_carrier);
} else {
$carrierSelected = new Carrier((int) $id_carrier);
}
$currency = $this->context->currency;
$rangeObj = $carrierSelected->getRangeObject();
$rangeTable = $carrierSelected->getRangeTable();
$suffix = $carrierSelected->getRangeSuffix();
$rangeIdentifier = 'id_' . $rangeTable;
$ranges = $rangeObj->getRanges($id_carrier);
$delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier);
$deliveryArray = array();
foreach ($delivery as $deliv) {
$deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
}
$this->context->smarty->assign(array('zones' => $carrierSelected->getZones(), 'carriers' => $carriers, 'ranges' => $ranges, 'currency' => $currency, 'deliveryArray' => $deliveryArray, 'carrierSelected' => $carrierSelected, 'id_carrier' => $id_carrier, 'suffix' => $suffix, 'rangeIdentifier' => $rangeIdentifier, 'action_fees' => self::$currentIndex . '&token=' . $this->token));
parent::initContent();
}
示例2: getTplRangesVarsAndValues
/**
* @param Carrier $carrier
* @param array $tpl_vars
* @param array $fields_value
*/
protected function getTplRangesVarsAndValues($carrier, &$tpl_vars, &$fields_value)
{
$tpl_vars['zones'] = Zone::getZones(false);
$carrier_zones = $carrier->getZones();
$carrier_zones_ids = array();
if (is_array($carrier_zones)) {
foreach ($carrier_zones as $carrier_zone) {
$carrier_zones_ids[] = $carrier_zone['id_zone'];
}
}
$range_table = $carrier->getRangeTable();
$shipping_method = $carrier->getShippingMethod();
$zones = Zone::getZones(false);
foreach ($zones as $zone) {
$fields_value['zones'][$zone['id_zone']] = Tools::getValue('zone_' . $zone['id_zone'], in_array($zone['id_zone'], $carrier_zones_ids));
}
if ($shipping_method == Carrier::SHIPPING_METHOD_FREE) {
$range_obj = $carrier->getRangeObject($carrier->shipping_method);
$price_by_range = array();
} else {
$range_obj = $carrier->getRangeObject();
$price_by_range = Carrier::getDeliveryPriceByRanges($range_table, (int) $carrier->id);
}
foreach ($price_by_range as $price) {
$tpl_vars['price_by_range'][$price['id_' . $range_table]][$price['id_zone']] = $price['price'];
}
$tmp_range = $range_obj->getRanges((int) $carrier->id);
$tpl_vars['ranges'] = array();
if ($shipping_method != Carrier::SHIPPING_METHOD_FREE) {
foreach ($tmp_range as $id => $range) {
$tpl_vars['ranges'][$range['id_' . $range_table]] = $range;
$tpl_vars['ranges'][$range['id_' . $range_table]]['id_range'] = $range['id_' . $range_table];
}
}
// init blank range
if (!count($tpl_vars['ranges'])) {
$tpl_vars['ranges'][] = array('id_range' => 0, 'delimiter1' => 0, 'delimiter2' => 0);
}
}
示例3: displayFormFees
public function displayFormFees()
{
global $currentIndex;
$carrierArray = array();
$id_carrier = Tools::getValue('id_carrier');
$carriers = Carrier::getCarriers((int) Configuration::get('PS_LANG_DEFAULT'), true, false, false, NULL, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
foreach ($carriers as $carrier) {
if (!$carrier['is_free']) {
$carrierArray[] = array('id' => $carrier['id_carrier'], 'display' => '<option value="' . (int) $carrier['id_carrier'] . '"' . ($carrier['id_carrier'] == $id_carrier ? ' selected="selected"' : '') . '>' . $carrier['name'] . '</option>');
}
}
if (count($carrierArray)) {
if (!$id_carrier) {
$id_carrier = (int) $carrierArray[0]['id'];
}
$carrierSelected = new Carrier($id_carrier);
}
echo '<br /><br />
<h2>' . $this->l('Fees by carrier, geographical zone, and ranges') . '</h2>
<form action="' . $currentIndex . '&token=' . $this->token . '" id="fees" name="fees" method="post">
<fieldset>
<legend><img src="../img/admin/delivery.gif" />' . $this->l('Fees') . '</legend>';
if (!count($carrierArray)) {
echo $this->l('You only have free carriers, there is no need to configure your delivery prices.');
} else {
echo '<b>' . $this->l('Carrier:') . ' </b>
<select name="id_carrier2" onchange="document.fees.submit();">';
foreach ($carrierArray as $carrierOption) {
echo $carrierOption['display'];
}
echo '
</select><br />
<table class="table space" cellpadding="0" cellspacing="0">
<tr>
<th>' . $this->l('Zone / Range') . '</th>';
$currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$rangeObj = $carrierSelected->getRangeObject();
$rangeTable = $carrierSelected->getRangeTable();
$suffix = $carrierSelected->getRangeSuffix();
$rangeIdentifier = 'id_' . $rangeTable;
$ranges = $rangeObj->getRanges($id_carrier);
$delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier);
foreach ($delivery as $deliv) {
$deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
}
if (!$carrierSelected->is_free) {
foreach ($ranges as $range) {
echo '<th style="font-size: 11px;">' . (double) $range['delimiter1'] . $suffix . ' ' . $this->l('to') . ' ' . (double) $range['delimiter2'] . $suffix . '</th>';
}
}
echo '</tr>';
$zones = $carrierSelected->getZones();
if (sizeof($ranges) && !$carrierSelected->is_free) {
if (sizeof($zones) > 1) {
echo '
<tr>
<th style="height: 30px;">' . $this->l('All') . '</th>';
foreach ($ranges as $range) {
echo '<td class="center">' . $currency->getSign('left') . '<input type="text" id="fees_all_' . $range[$rangeIdentifier] . '" onchange="this.value = this.value.replace(/,/g, \'.\');" onkeyup="if ((event.keyCode||event.which) != 9){ spreadFees(' . $range[$rangeIdentifier] . ') }" style="width: 45px;" />' . $currency->getSign('right') . '</td>';
}
echo '</tr>';
}
foreach ($zones as $zone) {
echo '
<tr>
<th style="height: 30px;">' . $zone['name'] . '</th>';
foreach ($ranges as $range) {
if (isset($deliveryArray[$zone['id_zone']][$id_carrier][$range[$rangeIdentifier]])) {
$price = $deliveryArray[$zone['id_zone']][$id_carrier][$range[$rangeIdentifier]];
} else {
$price = '0.00';
}
echo '<td class="center">' . $currency->getSign('left') . '<input type="text" class="fees_' . $range[$rangeIdentifier] . '" onchange="this.value = this.value.replace(/,/g, \'.\');" name="fees_' . $zone['id_zone'] . '_' . $range[$rangeIdentifier] . '" onkeyup="clearAllFees(' . $range[$rangeIdentifier] . ')" value="' . $price . '" style="width: 45px;" />' . $currency->getSign('right') . '</td>';
}
echo '
</tr>';
}
}
echo '<tr>
<td colspan="' . (sizeof($ranges) + 1) . '" class="center" style="border-bottom: none; height: 40px;">
<input type="hidden" name="submitFees' . $this->table . '" value="1" />';
if (sizeof($ranges) && !$carrierSelected->is_free) {
echo ' <input type="submit" value="' . $this->l(' Save ') . '" class="button" />';
} elseif ($carrierSelected->is_free) {
echo $this->l('This is a free carrier');
} else {
echo $this->l('No ranges set for this carrier');
}
echo '
</td>
</tr>';
echo '
</table>
<p>' . $this->l('Prices do not include tax.') . '</p>';
}
echo '
</fieldset>
<input type="hidden" name="id_carrier" value="' . $id_carrier . '" />
</form>';
}
示例4: install
public static function install()
{
$id_carrier = (int) Configuration::get(DpdPolandConfiguration::CARRIER_STANDARD_ID);
$carrier = self::getCarrierByReference((int) $id_carrier);
if ($id_carrier && Validate::isLoadedObject($carrier)) {
if (!$carrier->deleted) {
return true;
} else {
$carrier->deleted = 0;
return (bool) $carrier->save();
}
}
$carrier_standard = new DpdPolandCarrierStandardService();
$carrier = new Carrier();
$carrier->name = $carrier_standard->module_instance->l('DPD domestic shipment - Standard', self::FILENAME);
$carrier->active = 1;
$carrier->is_free = 0;
$carrier->shipping_handling = 1;
$carrier->shipping_external = 1;
$carrier->shipping_method = 1;
$carrier->max_width = 0;
$carrier->max_height = 0;
$carrier->max_depth = 0;
$carrier->max_weight = 0;
$carrier->grade = 0;
$carrier->is_module = 1;
$carrier->need_range = 1;
$carrier->range_behavior = 1;
$carrier->external_module_name = $carrier_standard->module_instance->name;
$carrier->url = _DPDPOLAND_TRACKING_URL_;
$delay = array();
foreach (Language::getLanguages(false) as $language) {
$delay[$language['id_lang']] = $carrier_standard->module_instance->l('DPD domestic shipment - Standard', self::FILENAME);
}
$carrier->delay = $delay;
if (!$carrier->save()) {
return false;
}
$dpdpoland_carrier = new DpdPolandCarrier();
$dpdpoland_carrier->id_carrier = (int) $carrier->id;
$dpdpoland_carrier->id_reference = (int) $carrier->id;
if (!$dpdpoland_carrier->save()) {
return false;
}
if (!copy(_DPDPOLAND_IMG_DIR_ . DpdPolandCarrierStandardService::IMG_DIR . '/' . _DPDPOLAND_STANDARD_ID_ . '.' . DpdPolandCarrierStandardService::IMG_EXTENTION, _PS_SHIP_IMG_DIR_ . '/' . (int) $carrier->id . '.jpg')) {
return false;
}
$range_obj = $carrier->getRangeObject();
$range_obj->id_carrier = (int) $carrier->id;
$range_obj->delimiter1 = 0;
$range_obj->delimiter2 = 1;
if (!$range_obj->save()) {
return false;
}
if (!self::assignCustomerGroupsForCarrier($carrier)) {
return false;
}
if (!Configuration::updateValue(DpdPolandConfiguration::CARRIER_STANDARD_ID, (int) $carrier->id)) {
return false;
}
return true;
}