Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CarrierFinder.php
Go to the documentation of this file.
1 <?php
7 
12 
17 {
21  private $carriersConfig;
22 
26  private $storeManager;
27 
33  public function __construct(
34  CarriersConfig $carriersConfig,
35  StoreManagerInterface $storeManager
36  ) {
37  $this->carriersConfig = $carriersConfig;
38  $this->storeManager = $storeManager;
39  }
40 
48  {
49  $request = new DataObject([
50  'dest_country_id' => $address->getCountryId()
51  ]);
52 
53  $carriers = [];
54  foreach ($this->carriersConfig->getActiveCarriers($this->storeManager->getStore()->getId()) as $carrier) {
55  $checked = $carrier->checkAvailableShipCountries($request);
56  if (false !== $checked && null === $checked->getErrorMessage() && !empty($checked->getAllowedMethods())) {
57  $carriers[] = $checked;
58  }
59  }
60 
61  return $carriers;
62  }
63 }
__construct(CarriersConfig $carriersConfig, StoreManagerInterface $storeManager)
$storeManager
$address
Definition: customer.php:38
$checked
Definition: billing.phtml:77