当前位置: 首页>>代码示例>>PHP>>正文


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怎么用?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;
 }
开发者ID:Zookal,项目名称:fontis_australia,代码行数:96,代码来源:Eparcel.php


注:本文中的Mage_Shipping_Model_Rate_Request::getWarehouseId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。