Example #1
0
 /**
  * @param \Magento\Quote\Model\Quote\Address\RateResult\AbstractResult $rate
  * @return $this
  */
 public function importShippingRate(\Magento\Quote\Model\Quote\Address\RateResult\AbstractResult $rate)
 {
     if ($rate instanceof \Magento\Quote\Model\Quote\Address\RateResult\Error) {
         $this->setCode($rate->getCarrier() . '_error')->setCarrier($rate->getCarrier())->setCarrierTitle($rate->getCarrierTitle())->setErrorMessage($rate->getErrorMessage());
     } elseif ($rate instanceof \Magento\Quote\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;
 }