From 3c31ce8a4bf4d72a55dbda97077e1d88db18d819 Mon Sep 17 00:00:00 2001 From: Daniel Nordstrom Date: Fri, 1 Nov 2024 11:21:53 -0400 Subject: [PATCH] When building the array of shipping rates, for the selected shipping method, use the rate from the quote --- Service/ExpressPay/QuoteConverter.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Service/ExpressPay/QuoteConverter.php b/Service/ExpressPay/QuoteConverter.php index fe9971e..3156fab 100644 --- a/Service/ExpressPay/QuoteConverter.php +++ b/Service/ExpressPay/QuoteConverter.php @@ -160,14 +160,16 @@ static function (Rate $rate) use (&$usedRateCodes): bool { if ($hasRequiredAddressData && count($shippingRates) > 0) { $convertedQuote['order_data']['shipping_options'] = array_map( - static function (Rate $rate) use ($currencyCode): array { + static function (Rate $rate) use ($currencyCode, $shippingAddress): array { + $price = ($rate->getCode() === $shippingAddress->getShippingMethod()) + ? $shippingAddress->getShippingAmount() : $rate->getPrice(); return [ 'id' => $rate->getCode(), 'label' => trim("{$rate->getCarrierTitle()} - {$rate->getMethodTitle()}", ' -'), 'type' => 'SHIPPING', 'amount' => [ 'currency_code' => $currencyCode ?? '', - 'value' => number_format((float)$rate->getPrice(), 2) + 'value' => number_format((float)$price, 2) ] ]; },