Comments (7)
Hey @Oliwillis, thanks so much for taking the time to report this issue.
What you're saying makes a lot of sense, and I can't really see any issue with changing the updateItemById
call to make use of the /update.js
endpoint instead of the /change.js
endpoint. I'll test out the change and put it through.
It also looks like your use case would be benefited by two planned features for CartJS, the first being allowing updating the quantities of multiple line items in one Ajax call and the second is a "transaction" mode, where you can "stack" multiple calls before calling something like commit()
, which would work out the minimum number of actual Ajax requests needed to perform all of the requested operations.
from cartjs.
Thanks that sounds great. Happy to assist in any beta testing if it helps you out.
from cartjs.
Thanks @Oliwillis. I just made that quick change and rebuilt the library on a branch called changejs
here.
It would be great if you could try out your use case with the appropriate dist
file you're using on your project and let me know if it all works okay. If so I'll do some further testing and then merge in to master.
Thanks again!
from cartjs.
Hi @gavinballard, thanks for the update but from what I can see from a brief test in dev (using 'simplified' code as posted above), it is not updating quantities to 0 or 1 at all...
The original code is also not working with the new cart.js``dist
- just adds 1 quantity on each click of the given variant and doesn't remove any. Hope that helps!
from cartjs.
Hey @Oliwillis, sorry about the dud code. Serves me right for not reading through stuff more thoroughly.
I've reverted those original changes back to the /change.js
endpoint, as looking at the docs that's more appropriate when you're dealing with a single line item.
However, I've now added a new API method, updateItemQuantitiesById
, which allows you to set the desired quantities of a number of variant IDs in one hit. I believe that will solve your current use case in a much nicer way than the current solution.
I've added some documentation on the new method here, but as an example you should now be able to do this:
CartJS.updateItemQuantitiesById({
1118014272: 0,
1118014280: 0,
1118014284: 1,
1118014276: 0
});
This new method is bundled in v0.2.2 of CartJS, which has been pushed to NPM and Bower (or you can just download from http://cartjs.org).
Let me know if you run in to any further problems!
from cartjs.
Hi @gavinballard , tested and working well - rolled out to live site.
Thanks for your attention to this!
from cartjs.
Great, thanks for the feedback! 👍
from cartjs.
Related Issues (20)
- New site for "Built With" Page: http://shop.thenewcompany.com/
- cart.requestComplete Vanilla js? HOT 2
- 'selling_plan_allocation' key is showing up twice in CartJS Line item properties.
- Feature: Option to output price without currency symbol
- New site for "Built With" Page: http://nunoo.eu
- cart.requestComplete not firing? HOT 1
- How can I add Error message when exceeding the product quantity in Mini cart? HOT 1
- "Required parameter missing or invalid: items" Error when adding to cart
- Callbacks functiona not wroking when I set selling_price option
- Liquid code in rivets.js
- New site for "Built With" Page: https://atlasteaclub.com/
- UpdateItem with quantity undefined does not leave quantity as-is
- Changes to cart.items results in unwanted class/functionality duplication
- New site for Waist Beads "Built With" Page: https://www.wisonline.com.ng/beads
- New site for "Built With" Page: http://web.com HOT 1
- After coming back from checkout, json has the old data HOT 2
- Hh HOT 1
- New site for "Built With" Page: http://file:///C:/Users/acer/Desktop/Cosmetics/index.html HOT 1
- Can we use it with core php project or its only for Shopify HOT 1
- Current status
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cartjs.