Closed thagxt closed 10 months ago
@thagxt Thank you that you noticed it. I guess Shopify changed their Cart API again. It didn't add anything to the cart if an error happens, now this behavior changed... I'll try to release a new version with the bug fixed after the weekend. Thank you!
Actually it looks like a bug on the Shopify side. When you send an Ajax request that returns an error, it shouldn't add anything to the cart, but it does.
Don't you have any insight on it, maybe you see an issue in the Shopify Github repository about it? I'm trying to find any information on if they are going to fix it or it will stay like this so I should fix Liquid Ajax Cart on my side.
The thing is, this bug exists in the Dawn theme as well. Looks like they aren't aware of this bug.
@thagxt I've also asked the question in the shopify community: https://community.shopify.com/c/technical-q-a/cart-api-add-js-wrong-behavior/m-p/2227468 Hoping that maybe we've got an official response from Shopify support (even though it is rarely happens lol).
Yes, it is an API issue. I reported it on Slack, and another dev who encountered the same problem in August suggested to open an issue on Dawn's repo, since this may be the only way for this to reach the right people at Shopify and get fixed hopefully. Let me know if you want to open it I'll upvote, if not I'll do.
Can you open it pls, I'll upvote a bit later.
If you use Liquid ajax Cart on production and this bug makes troubles for your case, let me know, I'll provide a script that will refresh the cart after product "add to cart" error. It will be just a few lines of code that use liquid ajax cart api.
Thank you @EvgeniyMukhamedjanov ! I'm not using it currently, but I'm considering migrating from cartjs.org
and was exploring alternatives to it and to the Dawn approach.
I've created the issue Here
I see. So basically the difference of Liquid Ajax Cart from cartjs is that cartjs uses shopify cart json response as data for the ajax cart, liquid ajax cart uses bundle section rendering, so you can use liquid objects as data for your ajax cart. Let me know if you have any questions.
liquid ajax cart approach is somehow like Dawn's approach, but you can't take dawn's code and copy paste to your theme, as it is tied to classnames, specific functionality etc :-)
Yes, I know... currently working on stripping Dawn down to keep only the things I need and hasn't been a fun process so far haha. However, I was interested in removing jQuery (cartjs.org) from an older project, and based on what you've said, your method appears to be the more appropriate one here. Thank you for your insight!
Question:
Could you provide a compiled/minified version of the liquid-ajax-cart.js
suitable for CDN use for instance? The current version outputted by webpack is very "ugly", and since I'm not well-versed in webpack and don't intend to use it, it would be great to have a straightforward method to just "plug-n-play" the cart JS into any theme without having to do the whole process and end up with a file like this :) thank you
@thagxt Sure, you can download the file here: https://liquid-ajax-cart.js.org/v2/releases/ or here, if you want to use the version 1: https://liquid-ajax-cart.js.org/v1/releases/
@thagxt It seems like the issue is fixed by Shopify? I don't see the wrong behavior anymore of the change.js/add.js requests.
UPD: so strange, worked yesterday, but doesn't work now...
UPD2: works differently on different stores. If you could test on yours, would be good.
I think Shopify fixed the problem, it is working as expected for me on the stores I've tested it on. 👍
Description: While experimenting with the ajax cart functionality, I identified a bug related to product quantity handling. Here's a breakdown:
When attempting to add a quantity of products larger than what's available, the system:
If I then try to reduce the product quantity, the system indicates that the specified number of products is already in the cart. However, the "drawer" and "cart bubble" only reflect the correct quantity after a page refresh.
https://github.com/EvgeniyMukhamedjanov/liquid-ajax-cart/assets/7128602/5643c7f2-7b81-4354-9c07-6c7d94d5add9