Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hello there,
I have a problem with my code. I create a new variation with the API, add it to the cart then fetch the cart. The cart will then contain the newly added item, but with a price of $0. If a wait a little bit (less than 1 second) and fetch again, the price will be set correctly. I feel like Shopify needs to process something before making the price available. I know I can fetch until the price is okay, but I was wondering if there is any other way to wait for the price to be set before redirecting to the cart page.
Thank you,
Vincent
There are a fair amount of delays in some of these mechanisms. In that there appears to be a round-trip between the API transaction completing, the back-end DB committing the change, and the new transaction appearing for a web/API consumer. I too ran into this when working with creating variants on the fly and adding them to cart. What I did was build in what I perceived to be the worst-case scenario in that round-trip response time. From what I recall it was something like 3 seconds. Most all scripting languages have "sleep" functions available, so I'd look toward that and testing things out!