I have a problem with discount not subtracted from grand total in checkout. The discount is coming from a cart rule and is displayed correctly on the checkout page but the grand total is without the discount value. In the image below the order total is 330 which should be 314 because of 16 discount value enter image description here

Although if I create the same order in guest user without login there is no problem. I tried to track it down but I am new to magneto and finding it hard to debug such a problem. Anyway I believe I found where the problem is but I don't know how to solve it, This is how i tracked the issue, when the page of checkout is loading the values appear correct for a second then disappear and replaced with wrong values, so i noticed this happen when shipping-information API is called I tracked the API in postman and found the totals returning from this API is without discount and if I comment out it's code the values appear correctly. I belevie the problem that a new address is added using this API but it doesn't contain the discount and the correct totals Here is the file that i beleive the issue in it /vendor/magento/module-checkout/Model/ShippingInformationManagement.php

public function saveAddressInformation(
    ShippingInformationInterface $addressInformation
): PaymentDetailsInterface {
    /** @var Quote $quote */
    $quote = $this->quoteRepository->getActive($cartId);

    $address = $addressInformation->getShippingAddress();

    if (!$address->getCustomerAddressId()) {

    try {
        $billingAddress = $addressInformation->getBillingAddress();
        if ($billingAddress) {
            if (!$billingAddress->getCustomerAddressId()) {
            $this->addressValidator->validateForCart($quote, $billingAddress);

        $this->addressValidator->validateForCart($quote, $address);
        $carrierCode = $addressInformation->getShippingCarrierCode();
        $methodCode = $addressInformation->getShippingMethodCode();
        $quote = $this->prepareShippingAssignment($quote, $address, $carrierCode . '_' . $methodCode);


    } catch (LocalizedException $e) {
        throw new InputException(
                'The shipping information was unable to be saved. Error: "%message"',
                ['message' => $e->getMessage()]
    } catch (\Exception $e) {
        throw new InputException(
            __('The shipping information was unable to be saved. Verify the input data and try again.')

    $shippingAddress = $quote->getShippingAddress();

    if (!$quote->getIsVirtual()
        && !$shippingAddress->getShippingRateByCode($shippingAddress->getShippingMethod())
    ) {
        $errorMessage = $methodCode ?
            __('Carrier with such method not found: %1, %2', $carrierCode, $methodCode)
            : __('The shipping method is missing. Select the shipping method and try again.');
        throw new NoSuchEntityException(

    /** @var PaymentDetailsInterface $paymentDetails */
    $paymentDetails = $this->paymentDetailsFactory->create();
    return $paymentDetails;

In the previous code if i remove $paymentDetails->setTotals($this->cartTotalsRepository->get($cartId)); the values not overridden and stay correctly

  • It will take time to debug your issue, let's go to this chat room for greater convenience and back to this question with the correct solution. chat.stackexchange.com/rooms/info/140377/…
    – Tu Van
    Commented Nov 5, 2022 at 6:41
  • Room link here chat.stackexchange.com/rooms/140377/…
    – Tu Van
    Commented Nov 5, 2022 at 6:48
  • Thanks i solved the issue by disabling mage plaza free gifts plugin
    – AlaaL
    Commented Nov 7, 2022 at 6:08
  • Glad to hear that.
    – Tu Van
    Commented Nov 7, 2022 at 6:29
  • Try in luma themeand disable all module and see if issue still exist
    – Pawan
    Commented Nov 11, 2022 at 2:01


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.