Open
Description
Preconditions and environment
- Magento version: 2.4.x
Steps to reproduce
- Add some products to cart.
- Perform checkout steps with address, shipment, payment
- Make sure a shipping address was set.
- Select Flat Rate - Fixed as shipping method.
- Observe the selected_shipping_method expected Flat Rate - Fixed
- 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
}
}
}
}
- Select Free - Free Shipping as shipping method.
- 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.
- 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”.