Missing or Incorrect Totals
Custom Total Segments Displaying Incorrect Totals
Sometimes, when using custom total segments such as those added by the Gift Card feature in Adobe Commerce, the totals
displayed to the customer are inaccurate or incomplete. In order to attempt to account for this, we added a new system
configuration option in version 1.1.23 of the Hyvä Checkout to toggle the
recollection of quote totals when the total segments are retrieved. This option can be located in the admin by
navigating to Stores -> Settings -> Configuration -> Hyvä Themes -> Hyvä Checkout -> Developer -> Fixes &
Workarounds -> Collect Totals During Segment Retrieval
and is enabled by default.
Caution
Recollecting totals multiple times during the same request may cause issues. If your installation contains customisations to recollect totals elsewhere, consider disabling this option via the admin to avoid unexpected behaviour.
Magento 2.4.3-p3 Missing or Incorrect Totals
This issue could only be reproduced in Magento 2.4.3-p3
and below.
In Magento 2.4.3-p3
, there is a known issue with shipping totals not updating correctly. This occurs due to an inconsistency in the way totals are collected during segment retrieval.
Current Bug Behavior
Shipping totals do not update unless the configuration value at:
Hyvä Checkout > Experimental > Fixes & Workarounds > Collect Totals During Segment Retrieval
is set toOff
.- When this setting is turned off, refreshing the checkout page causes the selected shipping method to reset to the previously selected option, instead of maintaining the current selection.
This behavior should not be dependent on this configuration setting. Instead, shipping totals should update dynamically regardless of the setting.
To manually apply the fix, use the following patch:
--- a/src/Magewire/Checkout/Shipping/MethodList.php
+++ b/src/Magewire/Checkout/Shipping/MethodList.php
@@ -10,6 +10,7 @@ declare(strict_types=1);
namespace Hyva\Checkout\Magewire\Checkout\Shipping;
+use Exception;
use Hyva\Checkout\Model\Magewire\Component\EvaluationInterface;
use Hyva\Checkout\Model\Magewire\Component\EvaluationResultFactory;
use Hyva\Checkout\Model\Magewire\Component\EvaluationResultInterface;
@@ -19,6 +20,7 @@ use Hyva\Checkout\Exception\CheckoutException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\StateException;
use Magento\Quote\Api\CartRepositoryInterface;
+use Magento\Quote\Model\ResourceModel\Quote;
use Magento\Quote\Model\ShippingMethodManagementInterface;
use Magewirephp\Magewire\Component;
use Psr\Log\LoggerInterface;
@@ -40,17 +42,20 @@ class MethodList extends Component implements EvaluationInterface
protected CartRepositoryInterface $quoteRepository;
protected ShippingMethodManagementInterface $shippingMethodManagement;
protected LoggerInterface $logger;
+ protected Quote $quoteResourceModel;
public function __construct(
SessionCheckout $sessionCheckout,
CartRepositoryInterface $quoteRepository,
ShippingMethodManagementInterface $shippingMethodManagement,
- LoggerInterface $logger
+ LoggerInterface $logger,
+ Quote $quoteResource
) {
$this->sessionCheckout = $sessionCheckout;
$this->quoteRepository = $quoteRepository;
$this->shippingMethodManagement = $shippingMethodManagement;
$this->logger = $logger;
+ $this->quoteResourceModel = $quoteResource;
}
public function boot(): void
@@ -76,14 +81,15 @@ class MethodList extends Component implements EvaluationInterface
if ($rate === false) {
throw new CheckoutException(__('Invalid shipping method'));
}
- if ($this->shippingMethodManagement->set($quote->getId(), $rate->getCarrier(), $rate->getMethod())) {
- $this->dispatchBrowserEvent('checkout:shipping:method-activate', ['method' => $value]);
- $this->emit('shipping_method_selected');
- }
- } catch (CheckoutException $exception) {
- $this->dispatchErrorMessage($exception->getMessage());
- } catch (LocalizedException $exception) {
+
+ $shippingAddress->setShippingMethod($rate->getCode());
+ $this->quoteResourceModel->save($quote->collectTotals());
+
+ $this->dispatchBrowserEvent('checkout:shipping:method-activate', ['method' => $value]);
+ $this->emit('shipping_method_selected');
+ } catch (CheckoutException|Exception $exception) {
$this->dispatchErrorMessage('Something went wrong while saving your shipping preferences.');
+ $this->logger->error($exception->getMessage());
}
return $value;