diff --git a/Model/ResourceModel/CashondeliveryTable.php b/Model/ResourceModel/CashondeliveryTable.php index da0c534..ef7195f 100644 --- a/Model/ResourceModel/CashondeliveryTable.php +++ b/Model/ResourceModel/CashondeliveryTable.php @@ -51,6 +51,14 @@ protected function _construct() */ public function getFee($amount, $country, $region) { + if (!$country) { + $country = ''; + } + + if (!$region) { + $region = ''; + } + $table = $this->getMainTable(); $currentWebsite = $this->storeManager->getWebsite()->getCode(); diff --git a/Model/Total/Quote/Cashondelivery.php b/Model/Total/Quote/Cashondelivery.php index 4bc6213..d152ab8 100644 --- a/Model/Total/Quote/Cashondelivery.php +++ b/Model/Total/Quote/Cashondelivery.php @@ -57,7 +57,11 @@ public function collect( } $country = $quote->getShippingAddress()->getCountryModel()->getData('iso2_code'); - $region = $quote->getShippingAddress()->getRegion(); + $region = $quote->getShippingAddress()->getRegionModel()->getData('code'); + + if (!$region && is_string($quote->getShippingAddress()->getRegion())) { + $region = $quote->getShippingAddress()->getRegion(); + } $baseAmount = $this->cashOnDeliveryInterface->getBaseAmount($total->getAllBaseTotalAmounts(), $country, $region); $amount = $this->priceCurrencyInterface->convert($baseAmount); diff --git a/Model/Total/Quote/CashondeliveryTax.php b/Model/Total/Quote/CashondeliveryTax.php index 16a3e31..a8bf297 100644 --- a/Model/Total/Quote/CashondeliveryTax.php +++ b/Model/Total/Quote/CashondeliveryTax.php @@ -55,7 +55,11 @@ public function collect( } $country = $quote->getShippingAddress()->getCountryModel()->getData('iso2_code'); - $region = $quote->getShippingAddress()->getRegion(); + $region = $quote->getShippingAddress()->getRegionModel()->getData('code'); + + if (!$region && is_string($quote->getShippingAddress()->getRegion())) { + $region = $quote->getShippingAddress()->getRegion(); + } $baseAmount = $this->cashOnDeliveryInterface->getBaseAmount($total->getAllBaseTotalAmounts(), $country, $region); diff --git a/etc/module.xml b/etc/module.xml index 908b17c..f7eb7d0 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -21,7 +21,7 @@ --> - +