How Do You Add A Product To A Cart Through The Api?

Hi, I'm exploring the API, and I understand how to fetch a cart and a product using the API. My question now is if there is a way to add a product through the API?

Hi, I'm exploring the API, and I understand how to fetch a cart and a product using the API. My question now is if there is a way to add a product through the API?

I am afraid, no

If you are referring to adding a product to a cart, no, the API doesn't support it. Years ago we created a controller/mode to add-to-cart/checkout from a remote location via a GET request. Ie. to add a product to a user's cart and either go to cart or go right to checkout. It was intended to use in blogs or remote advertising.

As far as I know it still works and is free. You can fetch it from https://ez-ms.com/private/unsupported_scripts/checkout.pre.php.txtand you can modify it to suit your needs.

If you are asking about adding a product via the API there is most certainly a create() method in the Products.php entity.

I see, then do you know how the the mobile app from CS Cart add products to the cart? Do they send a request to a dispatch, then in the dispatch, they retrieve the cart, add the product, then save the cart to the database? And then retrieve the cart again on mobile?

Alternatively, could I extend the API to do this? In the parameters for my extension I would give the user id, and then product ID and then run the fn_add_product_to_cart function and then save the cart through fn_save_cart_content?

I see, then do you know how the the mobile app from CS Cart add products to the cart? Do they send a request to a dispatch, then in the dispatch, they retrieve the cart, add the product, then save the cart to the database? And then retrieve the cart again on mobile?

CS-Cart contains invisible module called storefront_rest_api. Looks like it do what you need. But it does not have any documentation. If you are familiar with PHP, examine the module to find a way to add products to cart through API

And the module storefront_rest_api is very easy to extend by own custom addons.

We have created a full frontend with the storefront_rest_api. It is fully integrated in our community framework.

But you must be logged (the User who is using the cart) in, to use the cart by storefront_rest_api.

Hi, thanks for this. Where are the files for the storefront_rest_api located?

Nevermind, I found it. I assume it's not as easy as using it the same way the normal API is used? Because I keep getting "The Entity is not found, when I use the names of their classes". Any hint on how to use them? Or a specific file I should look into?

could you please help to get all information of user in user API like address,city etc

If you are referring to adding a product to a cart, no, the API doesn't support it. Years ago we created a controller/mode to add-to-cart/checkout from a remote location via a GET request. Ie. to add a product to a user's cart and either go to cart or go right to checkout. It was intended to use in blogs or remote advertising.

As far as I know it still works and is free. You can fetch it from https://ez-ms.com/private/unsupported_scripts/checkout.pre.php.txtand you can modify it to suit your needs.

If you are asking about adding a product via the API there is most certainly a create() method in the Products.php entity.

Thank you for your great help.
I am trying to implement this file:
http://ez-ms.com/private/unsupported_scripts/checkout.pre.php.txt
I created the php file under:
app/addons/controllers/customer/checkout.pre.php
also
design/bright_theme/templates/addons/controllers/customer/checkout.pre.php
I tried different URL patterns like below:
domain/index.php?dispatch=checkout.remote_add.gbr_FS-S1000R-2017-RHS-SEC-S1000RR-2009-SET-GBR.3
domain/index.php?dispatch=checkout.remote_checkout.gbr_FS-S1000R-2017-RHS-SEC-S1000RR-2009-SET-GBR@1&c_code=
domain/index.php?dispatch=checkout.remote_checkout.gbr_FS-S1000R-2017-RHS-SEC-S1000RR-2009-SET-GBR.1&c_code=
domain/index.php?dispatch=checkout.remote_add.gbr_FS-S1000R-2017-RHS-SEC-S1000RR-2009-SET-GBR.1&c_code=
None of above is working and I am stuck at some point which I am not understanding.
Kindly I ask your help, what can be the issue.
Thank You for your time and patience.

You should install it as app/addons/my_changes/controllers/frontend/checkout.pre.php

To use a pre/post controller module, you install it within a addon. controllers/filename will get you no where. It should be theme independent since there is no real front-end components. You sould invoke it (as documented in the script itself) as ?dipatch=checkout.remote_add.[product code]&[your list of options]

Thank you for your great help.
I am trying to implement this file:
I created the php file under:
app/addons/controllers/customer/checkout.pre.php
also
design/bright_theme/templates/addons/controllers/customer/checkout.pre.php
I tried different URL patterns like below:
domain/index.php?dispatch=checkout.remote_add.gbr_FS-S1000R-2017-RHS-SEC-S1000RR-2009-SET-GBR.3
domain/index.php?dispatch=checkout.remote_checkout.gbr_FS-S1000R-2017-RHS-SEC-S1000RR-2009-SET-GBR@1&c_code=
domain/index.php?dispatch=checkout.remote_checkout.gbr_FS-S1000R-2017-RHS-SEC-S1000RR-2009-SET-GBR.1&c_code=
domain/index.php?dispatch=checkout.remote_add.gbr_FS-S1000R-2017-RHS-SEC-S1000RR-2009-SET-GBR.1&c_code=
None of above is working and I am stuck at some point which I am not understanding.
Kindly I ask your help, what can be the issue.
Thank You for your time and patience.

You should install it as app/addons/my_changes/controllers/frontend/checkout.pre.php

To use a pre/post controller module, you install it within a addon. controllers/filename will get you no where. It should be theme independent since there is no real front-end components. You sould invoke it (as documented in the script itself) as ?dipatch=checkout.remote_add.[product code]&[your list of options]

You should install it as app/addons/my_changes/controllers/frontend/checkout.pre.php

To use a pre/post controller module, you install it within a addon. controllers/filename will get you no where. It should be theme independent since there is no real front-end components. You sould invoke it (as documented in the script itself) as ?dipatch=checkout.remote_add.[product code]&[your list of options]

Thank you so much it works !!!

You should install it as app/addons/my_changes/controllers/frontend/checkout.pre.php

To use a pre/post controller module, you install it within a addon. controllers/filename will get you no where. It should be theme independent since there is no real front-end components. You sould invoke it (as documented in the script itself) as ?dipatch=checkout.remote_add.[product code]&[your list of options]

Thank you so much it works !!!

Of course it works! :-)

I need some help. I'm new to the whole API thing. We have a new inventory system that supports API and CS-Cart that supports API. I have the URLS for both and the key.

We have 5 website that I need to keep the product amount current as well as posturing new SO to our inventory software (Traverse) I can create a PHP scripted and add it to my cron list but I think there is a better way of doing this, I just can't find it.

Anyone have examples of what you are using?

Thanks for the help

You'll have to do two things:

1 - as you've done, create some form of inventory synchronization that runs at a frequency you want (assuming cs-cart is the slave and your inventory system is the master).

2 - Create a post controller to update your inventory system in real-time when an order is created debiting the products that were sold. Your inventory system must support increment/decrement versus full amount to be successful.

I see, then do you know how the the mobile app from CS Cart add products to the cart? Do they send a request to a dispatch, then in the dispatch, they retrieve the cart, add the product, then save the cart to the database? And then retrieve the cart again on mobile?

The "Storefront REST API" module is used to do it. But it does not have any documentation.

You'll have to do two things:

1 - as you've done, create some form of inventory synchronization that runs at a frequency you want (assuming cs-cart is the slave and your inventory system is the master).

2 - Create a post controller to update your inventory system in real-time when an order is created debiting the products that were sold. Your inventory system must support increment/decrement versus full amount to be successful.

I'm new to API calls are there postman examples of the calls or the post/pre controllers?

Thanks

I have no idea what the specification of your inventory management system is for their API.

It's a development project specific to your targeted system.