예제 #1
0
파일: Rate.php 프로젝트: aiesh/magento2
 /**
  * @param \Magento\Sales\Model\Quote\Address\RateResult\AbstractResult $rate
  * @return $this
  */
 public function importShippingRate(\Magento\Sales\Model\Quote\Address\RateResult\AbstractResult $rate)
 {
     if ($rate instanceof \Magento\Sales\Model\Quote\Address\RateResult\Error) {
         $this->setCode($rate->getCarrier() . '_error')->setCarrier($rate->getCarrier())->setCarrierTitle($rate->getCarrierTitle())->setErrorMessage($rate->getErrorMessage());
     } elseif ($rate instanceof \Magento\Sales\Model\Quote\Address\RateResult\Method) {
         $this->setCode($rate->getCarrier() . '_' . $rate->getMethod())->setCarrier($rate->getCarrier())->setCarrierTitle($rate->getCarrierTitle())->setMethod($rate->getMethod())->setMethodTitle($rate->getMethodTitle())->setMethodDescription($rate->getMethodDescription())->setPrice($rate->getPrice());
     }
     return $this;
 }
예제 #2
0
파일: Result.php 프로젝트: aiesh/magento2
 /**
  * Add a rate to the result
  *
  * @param \Magento\Sales\Model\Quote\Address\RateResult\AbstractResult|\Magento\Shipping\Model\Rate\Result $result
  * @return $this
  */
 public function append($result)
 {
     if ($result instanceof \Magento\Sales\Model\Quote\Address\RateResult\Error) {
         $this->setError(true);
     }
     if ($result instanceof \Magento\Sales\Model\Quote\Address\RateResult\AbstractResult) {
         $this->_rates[] = $result;
     } elseif ($result instanceof \Magento\Shipping\Model\Rate\Result) {
         $rates = $result->getAllRates();
         foreach ($rates as $rate) {
             $this->append($rate);
         }
     }
     return $this;
 }