Ejemplo n.º 1
0
 /**
  * Obtain available carriers instances
  *
  * @return array
  */
 public function getCarriers()
 {
     if (null === $this->_carriers) {
         $this->_carriers = [];
         $this->getEstimateRates();
         foreach ($this->_rates as $rateGroup) {
             if (!empty($rateGroup)) {
                 foreach ($rateGroup as $rate) {
                     $this->_carriers[] = $this->_carrierFactory->get($rate->getCarrier());
                 }
             }
         }
     }
     return $this->_carriers;
 }
Ejemplo n.º 2
0
 /**
  * Get carrier by its code
  *
  * @param string $carrierCode
  * @param null|int $storeId
  * @return bool|\Magento\Shipping\Model\Carrier\AbstractCarrier
  */
 public function getCarrierByCode($carrierCode, $storeId = null)
 {
     if (!$this->scopeConfig->getValue('carriers/' . $carrierCode . '/active', 'store', $storeId)) {
         return false;
     }
     $className = $this->scopeConfig->getValue('carriers/' . $carrierCode . '/model', 'store', $storeId);
     if (!$className) {
         return false;
     }
     $carrier = $this->carrierFactory->get($carrierCode);
     if ($storeId) {
         $carrier->setStore($storeId);
     }
     return $carrier;
 }