Skip to content

Commit d346303

Browse files
committed
AC-15004::When we Enable Free Shipping Threshold for particular USPS shipping method in front store shipping price is not showing zero.
1 parent 151d31f commit d346303

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

app/code/Magento/Usps/Model/ShipmentService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public function _parseJsonResponse($response): Result
318318

319319
$shippingCost = (float)$method['price'];
320320
$rate->setCost($shippingCost);
321-
$rate->setPrice($this->carrierModel->getMethodPrice($shippingCost));
321+
$rate->setPrice($this->carrierModel->getMethodPrice($shippingCost, $method['code']));
322322

323323
/** @var Result $result */
324324
$result->append($rate);

app/code/Magento/Usps/Model/Source/Freemethod.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@
1010
*/
1111
class Freemethod extends Method
1212
{
13+
/**
14+
* @param \Magento\Usps\Model\Carrier $shippingUsps
15+
*/
16+
public function __construct(\Magento\Usps\Model\Carrier $shippingUsps)
17+
{
18+
parent::__construct($shippingUsps);
19+
$this->code = $this->getUspsTypeMethodCode();
20+
}
21+
22+
/**
23+
* Get dynamic code based on USPS type configuration
24+
*
25+
* @return string
26+
*/
27+
private function getUspsTypeMethodCode(): string
28+
{
29+
$uspsType = $this->shippingUsps->getConfigData('usps_type');
30+
31+
return match ($uspsType) {
32+
'USPS_REST' => 'rest_method',
33+
default => 'method',
34+
};
35+
}
1336
/**
1437
* @inheritDoc
1538
*/

0 commit comments

Comments
 (0)