本文整理汇总了PHP中Mage_Shipping_Model_Rate_Request::getWarehouseId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Shipping_Model_Rate_Request::getWarehouseId方法的具体用法?PHP Mage_Shipping_Model_Rate_Request::getWarehouseId怎么用?PHP Mage_Shipping_Model_Rate_Request::getWarehouseId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Shipping_Model_Rate_Request
的用法示例。
在下文中一共展示了Mage_Shipping_Model_Rate_Request::getWarehouseId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRate
public function getRate(Mage_Shipping_Model_Rate_Request $request)
{
$read = $this->_getReadAdapter();
$postcode = $request->getDestPostcode();
$table = $this->getMainTable();
$storeId = $request->getStoreId();
$insuranceStep = (double) Mage::getStoreConfig('carriers/eparcel/insurance_step', $storeId);
$insuranceCostPerStep = (double) Mage::getStoreConfig('carriers/eparcel/insurance_cost_per_step', $storeId);
$signatureRequired = Mage::getStoreConfigFlag('carriers/eparcel/signature_required', $storeId);
if ($signatureRequired) {
$signatureCost = (double) Mage::getStoreConfig('carriers/eparcel/signature_cost', $storeId);
} else {
$signatureCost = 0;
}
for ($j = 0; $j < 5; $j++) {
$select = $read->select()->from($table);
// Support for Multi Warehouse Extension.
if ($request->getWarehouseId() > 0) {
$select->where('stock_id = ?', $request->getWarehouseId());
}
switch ($j) {
case 0:
$select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_region_id=? ", $request->getDestRegionId()) . $read->quoteInto(" AND dest_zip=?) ", $postcode));
break;
case 1:
$select->where($read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_region_id=? AND dest_zip='0000') ", $request->getDestRegionId()));
break;
case 2:
$select->where($read->quoteInto(" (dest_country_id=? AND dest_region_id='0' AND dest_zip='0000') ", $request->getDestCountryId()));
break;
case 3:
$select->where($read->quoteInto(" (dest_country_id=? AND dest_region_id='0' ", $request->getDestCountryId()) . $read->quoteInto(" AND dest_zip=?) ", $postcode));
break;
case 4:
$select->where(" (dest_country_id='0' AND dest_region_id='0' AND dest_zip='0000')");
break;
}
if (is_array($request->getConditionName())) {
$i = 0;
foreach ($request->getConditionName() as $conditionName) {
if ($i == 0) {
$select->where('condition_name=?', $conditionName);
} else {
$select->orWhere('condition_name=?', $conditionName);
}
$select->where('condition_from_value<=?', $request->getData($conditionName));
$select->where('condition_to_value>=?', $request->getData($conditionName));
$i++;
}
} else {
$select->where('condition_name=?', $request->getConditionName());
$select->where('condition_from_value<=?', $request->getData($request->getConditionName()));
$select->where('condition_to_value>=?', $request->getData($request->getConditionName()));
}
$select->where('website_id=?', $request->getWebsiteId());
$select->order('dest_country_id DESC');
$select->order('dest_region_id DESC');
$select->order('dest_zip DESC');
$select->order('condition_from_value DESC');
// pdo has an issue. we cannot use bind
$newdata = array();
$row = $read->fetchAll($select);
if (!empty($row) && $j < 5) {
// have found a result or found nothing and at end of list!
foreach ($row as $data) {
try {
$price = (double) $data['price'];
// add per-Kg cost
$conditionValue = (double) $request->getData($request->getConditionName());
$price += (double) $data['price_per_kg'] * $conditionValue;
// add signature cost
$price += $signatureCost;
// add version without insurance
$data['price'] = (string) $price;
$newdata[] = $data;
if (Mage::getStoreConfig('carriers/eparcel/insurance_enable', $storeId)) {
// add version with insurance
// work out how many insurance 'steps' we have
$steps = ceil($request->getPackageValue() / $insuranceStep);
// add on number of 'steps' multiplied by the
// insurance cost per step
$insuranceCost = $insuranceCostPerStep * $steps;
$price += $insuranceCost;
$data['price'] = (string) $price;
$data['delivery_type'] .= " with TransitCover";
$newdata[] = $data;
}
} catch (Exception $e) {
Mage::log($e->getMessage());
}
}
break;
}
}
return $newdata;
}