When I do a /change or /update request, I get the entire cart back as a response, which is super convenient because I need to access the full state of the cart after each request.
The problem is, when I make an /add request, it only returns the added item, which forces me to fetch the full cart again with a /cart.json request, doubling the time it takes to access all necessary data.
Is there a way to access the full cart instantly after the /add request, without needing to fetch the cart again? Ty
You can keep your own state of the cart, though. I’ve seen some interesting solutions of that using Alpine store. If I remember correct the B2B Keystone theme does this.
Yeah that’s exactly what I’m trying to do! The catch is that my theme extension needs to keep up with the product prices, and each time that you make an /add request, automatic discounts could have been applied and I don’t have any way of noticing it.
For example: if the customer has 2 products in cart totaling $2000, and he adds a $500 product, I can assume that the new cart total is $2500, but in reality an automatic discount was applied for orders above $2200 that affected the other 2 products too, resulting in a new total of $1800 that I have no way to calculate. Does this make sense?
The only discounts that I could access in this situation are inside the discounts property of the added product, which wouldn’t be enough information to know that the total is $1800.
I know this is super specific but it’s super important for my extension to keep up with the real total, and I was searching for ways to achieve it without too many requests.
But anyway, still, thank you for your reply @curzey ! I just wanted to make sure there weren’t any other ways I didn’t know of. I hope to see you in editions!