Comments (13)
The documentation is outdated and I will get round to updating it when I can afford to spend time on it.
The API works with or without authentication but works best when not authenticating as a user. The API shows what you have in the cart, either added directly from your site or via the API.
The API acts just like the cart on the site. No more, no less.
from co-cart.
So this command http://domain.com/wp-json/wc/v2/cart/ -u consumer_key:consumer_secret
would pull the cart for the user that i'm sending through?
from co-cart.
Correct
from co-cart.
Great, thanks seb. I'll try that out tomorrow.
Also happy to contribute to the docs, I'll let you know how it all goes.
from co-cart.
So in order to have an individual subscriber of our site have their cart accessed via the API, we would need to automatically generate each user a consumer_key and consumer_secret? Or have them authorize our app like this? http://woocommerce.github.io/woocommerce-rest-api-docs/images/woocommerce-auth-endpoint-flow.png
from co-cart.
@JosephCarrington yep exactly, i've written a function that generates the keys whenever a user registers in WordPress and stores them in their user info, and they are then passed in a JWT token to the client.
from co-cart.
I have just installed the plugin. But without the documentation, I have some problems.
I've tested the API with Postman and all works fine. But when I use it inside my website (without authentification), it is not working. (I am not creating my own web app but I want to use the API inside the initial wordpress-woocommerce website).
Do I have to use authentification? @botoxparty could you precise how you did that?
from co-cart.
@BlueCloud02 Documentation has moved. You can access it here: https://co-cart.github.io/co-cart-docs/
from co-cart.
@BlueCloud02 For users without authentication I store the responses from the API into localstorage and build the cart like that, if a user logs in then the cart in localstorage is merged into their account's cart.
Would be great if there was some way of the API keeping up with carts for unauthenticated users using a cookie or something even.. Feature request?
from co-cart.
The WooCommerce cart does use cookies and sessions. It's just encrypted as a hash, I think. You will have to use the cart normally and then look for what the value of the cookie WooCommerce saves to confirm.
from co-cart.
@seb86 Hmm i understand that the cart uses cookies and sessions however getting the API to refer to these particular sessions or cookies isn't documented. I'd be happy to help write the docs to perform these actions if you're willing to chat about it over slack or something?
This project has helped me a lot with my work and am very happy to contribute to driving it forward.
from co-cart.
@botoxparty The documentation is available here should wish to make a contribution but please know that I will be making some changes myself soon so you will have to keep an eye out for changes pushed.
Simply fork the repo and apply your contribution then make a pull request. I will then review and merge if all good.
Thank you.
from co-cart.
@botoxparty Sorry forgot to provide a link to the documentation. https://github.com/co-cart/co-cart-docs which I have just updated. More is to come but you are welcome to contribute to it now.
from co-cart.
Related Issues (20)
- Totals calculations are not right when a custom price is set for the product HOT 6
- Tweak: New installation of CoCart should not run if WooCommerce is not installed HOT 2
- Undefined session functions due to CoCart not keeping function names the same as WooCommerce session handler HOT 4
- Yoast head field for products API HOT 3
- Products disappear when you restore cart HOT 3
- Bug: Unable to validate product data passed when updating item quantity. Product data returns null HOT 4
- [Enhancement]: Add product validation for when attempting to update an item's quantity should the product no longer exists HOT 4
- JWT Authentication not working anymore. HOT 4
- Incorrect subtotal price? HOT 17
- There is no way to apply taxes and coupons with CoCart Cart while frontend cart/checkout page. HOT 3
- [Vulnerability] : Any user can choose price for products on cart HOT 1
- Custom Price Ignored after Load Cart from Session HOT 3
- Guest users cart is cleared when increasing quantity from the cart. HOT 1
- [Enhancement]: Authenticate via phone number HOT 1
- Mixing carts between users HOT 1
- Sync repository labels action test
- Updating a cart or removing an item from a cart add random products to the cart HOT 1
- problem with multiple reqs in a row HOT 1
- cookies and subdomains HOT 2
- TODO: Update WordPress plugin directory banner
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 co-cart.