Skip to content

Commit

Permalink
Fix exception when no extension attributes have been loaded yet
Browse files Browse the repository at this point in the history
  • Loading branch information
PhoenixDev - JJ committed Jan 16, 2018
1 parent e928646 commit 0fb8dc5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Model/CashOnDelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@ public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
return $available;
}

$shippingMethods = $quote->getExtensionAttributes()->getShippingAssignments();

$disallowedShippingMethods = $this->getDisallowedShippingMethods();
foreach ($shippingMethods as $shippingMethod) {
if (in_array($shippingMethod->getShipping()->getMethod(), $disallowedShippingMethods)) {
$available = false;
$extensionAttributes = $quote->getExtensionAttributes();
if ($extensionAttributes !== null) {
$shippingMethods = $extensionAttributes->getShippingAssignments();

$disallowedShippingMethods = $this->getDisallowedShippingMethods();
foreach ($shippingMethods as $shippingMethod) {
if (in_array($shippingMethod->getShipping()->getMethod(), $disallowedShippingMethods)) {
$available = false;
}
$shippingMethod->getShipping()->getMethod();
}
$shippingMethod->getShipping()->getMethod();
}

return $available;
Expand Down

0 comments on commit 0fb8dc5

Please sign in to comment.