Page 1 of 1
api question, cart
Posted: Thu Jun 06, 2024 3:32 pm
by haydent
when using api cart functions for existing customer does it create a new cart, or will it be the existing one the customer may have going ?
Re: api question, cart
Posted: Thu Jun 06, 2024 7:58 pm
by paulfeakins
haydent wrote: ↑Thu Jun 06, 2024 3:32 pm
when using api cart functions for existing customer does it create a new cart, or will it be the existing one the customer may have going ?
Why not try it and find out?
Re: api question, cart
Posted: Fri Jun 07, 2024 6:13 am
by haydent
im guessing this means you dont know

i didnt think i could test it as it seems common opinion here that past versions of oc it didnt work or was complete,
but i noticed i think the admin add order feature uses it, and i was looking at the code and it seems a customers does have separate carts, one for themself and one for each api user.
Re: api question, cart
Posted: Fri Jun 07, 2024 6:12 pm
by JNeuhoff
It should use the customer's existing cart, see also the DB table oc_cart which contains both the api_id and customer_id.
However, there are some known issues with the usage of the API in OC 4.0.2.3, so you shouldn't rely on the API. Or use a stable OpenCart 3.0.3.9 or 3.0.4.0 version for a live website, or wait for the upcoming 4.1.0.0 or later.
Re: api question, cart
Posted: Sun Jun 09, 2024 4:05 pm
by haydent
Hey thanks for the feedback, i was looking at that table and the models that work with it. Im already running 4.0.1.1 live, will upgrade some day but just exploring the existing state of the api in my version. From what i can see each api user would create their own version of a customers cart.
Re: api question, cart
Posted: Tue Jun 11, 2024 8:03 am
by straightlight
haydent wrote: ↑Sun Jun 09, 2024 4:05 pm
Hey thanks for the feedback, i was looking at that table and the models that work with it. Im already running 4.0.1.1 live, will upgrade some day but just exploring the existing state of the api in my version. From what i can see each api user would create their own version of a customers cart.
I would still await for at least OC v4.1.0.0+ before using the API due to the so many changes that were involved over the years. By using the built-in store instance as a model, you could take a look in the core on how it has been developed as part of the existing state. One specific location where you could also take a look would be in the catalog/controller/api/order.php file for more information.
Re: api question, cart
Posted: Mon Jul 01, 2024 6:12 pm
by haydent
I did some more testing and i was a bit off, so each api user has thier own cart, separate from each customers cart,