Skip to content

Cart adapter for customer data storage cache is missing on the server side, causing issues when using a combination of headful and headless approaches #39374

Open
@tuyennn

Description

@tuyennn

Preconditions and environment

  • Magento version: 2.4.x

Steps to reproduce

  1. Add some products to cart.
  2. Perform checkout steps with address, shipment, payment
  3. Make sure a shipping address was set.
  4. Select Flat Rate - Fixed as shipping method.
  5. Observe the selected_shipping_method expected Flat Rate - Fixed
  6. Perform getcart graphql query {cart(cart_id: String!) {Cart}} to get current cart information
{
  cart(cart_id: "KWN2HqDtvs7M7acbUilpa39jw5Ktd7Sx") {
    email
    billing_address {
      city
      country {
        code
        label
      }
      firstname
      lastname
      postcode
      region {
        code
        label
      }
      street
      telephone
    }

    shipping_addresses {
      firstname
      lastname
      street
      city
      region {
        code
        label
      }
      country {
        code
        label
      }
      telephone

      available_shipping_methods {

        amount {
          currency
          value
        }

        available
        carrier_code
        carrier_title
        error_message
        method_code
        method_title
        price_excl_tax {
          value
          currency
        }

        price_incl_tax {
          value
          currency
        }

      }

      selected_shipping_method {
        amount {
          value
          currency
        }
        carrier_title
        method_title
      }
    }

    available_payment_methods {
      code
      title
    }

    selected_payment_method {
      code
      title
    }

    applied_coupons {
      code
    }

    prices {
      grand_total {
        value
        currency
      }
    }
  }
}
  1. Select Free - Free Shipping as shipping method.
  2. Observe the selected_shipping_method , still Flat Rate - Fixed

Expected result

  • selected_shipping_method consistent while performing get cart graphql and last selected state

Actual result

  • selected_shipping_method inconsistent while performing get cart graphql and last selected state
  • cart-data information could not be accessed from GraphQl, restAPI for current quote
CartAdapter-2024-11-20_14.54.53.mp4

Additional information

  • Observe the mage-cache-storage.
  • The cart-data stores cart information in the customer's local storage (localStorage) without saving it on the server.
    image
  • The cart-data can be accessed by other services, such as GraphQL and REST API, to retrieve the current quote. This is important because multiple services can use the same resource and transfer customer data between headful and headless systems, such as AEM pages and Luma-based stores.
  • For reference, this cache is implemented in the following file: https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Checkout/view/frontend/web/js/model/cart/cache.js, which stores cart data in the customer's local storage without saving it on the server.
  • When a customer selects a shipping method during checkout, Magento calls the REST API endpoint rest/V1/guest-carts/{cartId}/totals-information or /rest/default/V1/carts/mine/totals-information. However, this does not save the selected shipping method or totals at the server level. Instead, only the cart data (cart-data) is cached in the customer's local storage.
  • Suggestion: Implement server-side caching for the selected totals and shipping methods. This would allow other services to access the cached totals, ensuring consistency across different systems.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Cart & CheckoutComponent: GraphQLGraphQLIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReported on 2.4.xIndicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions