Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

Commit

Permalink
FIX issue #31 - error while selecting shipping address
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix128 committed Aug 24, 2017
1 parent 154353a commit fb1c55e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Model/ResourceModel/CashondeliveryTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 5 additions & 1 deletion Model/Total/Quote/Cashondelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion Model/Total/Quote/CashondeliveryTax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="MSP_CashOnDelivery" setup_version="1.2.0">
<module name="MSP_CashOnDelivery" setup_version="1.2.1">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit fb1c55e

Please sign in to comment.