Ensuring Cart Initialization Across All Pages #2395
Unanswered
bonamsrikanth1
asked this question in
Help
Replies: 1 comment
-
Interesting one. This will have a negative effect on performance, because you would have to wait for a new cart to be created before rendering the page. If you still want to explore this, you could change the Pseudo-code:
mutation cartCreate(input: {}) {
cartCreate {
cart {
id
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello Team, reaching out to discuss an issue we've encountered regarding cart initialization on our Hydrogen 2 website.
Current Challenge:
-We have observed that the cart ID is only created when a product is first added to the cart. This means the cart is not instantiated on page load if no products are added.
-We need the cart ID to be available on every page load, as we use it as a unique identifier to match client-side events with server-side purchase events received through Shopify webhooks.
Use Case: If a user clicks the "Buy Now" button and goes directly to checkout without adding anything to the cart, the cart ID is not available on page load. This leads to challenges in tracking and linking purchase events.
I've noticed the same on skeleton template:
https://github.com/Shopify/hydrogen/tree/main/templates/skeleton
Request for Assistance:
Could you provide guidance on how to ensure the cart is instantiated with an ID on every page load, regardless of whether a product is added to cart? Any insights into existing features or workarounds would be greatly appreciated.
Thank you for your support.
Beta Was this translation helpful? Give feedback.
All reactions