Skip to content

Commit

Permalink
Merge pull request #70 from Trunkrs/develop
Browse files Browse the repository at this point in the history
Update: add check for optional parameter - postal code
  • Loading branch information
fmsthird authored Sep 22, 2023
2 parents 0bde78f + 62e1750 commit 7df6080
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions Model/Carrier/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,14 @@ public function getTrunkrsShippingMethod()
$urlHost = $this->getShipmentMethodEndpoint();
$client = new Client();

if(!empty($postalCode)) {
$trunkrsEndpoint = $urlHost . "?country=" . $country . "&postalCode=" . $postalCode. "&orderValue=" . $totalAmount;
} else {
$trunkrsEndpoint = $urlHost . "?country=" . $country . "&orderValue=" . $totalAmount;
}

$request = $client->get(
$urlHost . "?country=" . $country . "&postalCode=" . $postalCode. "&orderValue=" . $totalAmount, [
$trunkrsEndpoint, [
'headers' => [
'Authorization' => sprintf('Bearer %s', $this->getAccessToken()),
'Content-Type' => 'application/json; charset=utf-8'
Expand Down Expand Up @@ -207,7 +213,7 @@ public function isTrackingAvailable()

/**
* Retrieves customer country
* @return string
* @return string|null
*/
public function getCountry()
{
Expand All @@ -216,7 +222,7 @@ public function getCountry()

/**
* Retrieves customer postcode
* @return string
* @return string|null
*/
public function getPostalCode()
{
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"trunkrs magento 2 shipping method"
],
"type": "magento2-module",
"version": "2.4.0",
"version": "2.4.1",
"license": [
"MIT"
],
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Trunkrs_Carrier" setup_version="2.4.0">
<module name="Trunkrs_Carrier" setup_version="2.4.1">
<sequence>
<module name="Magento_Backend"/>
<module name="Magento_Config"/>
Expand Down
2 changes: 1 addition & 1 deletion view/adminhtml/templates/system/config/trunkrs.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ echo "<div id='trunkrs-app'></div>";
'browserInfo' => $_SERVER['HTTP_USER_AGENT'],
'phpVersion' => phpversion(),
'phpExtensions' => get_loaded_extensions(),
'pluginVersion' => 'v2.4.0'
'pluginVersion' => 'v2.4.1'
],
'disableAutoShipment' => $block->getDisableAutoShipment()
]);
Expand Down

0 comments on commit 7df6080

Please sign in to comment.