Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

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

 
  • bebopboy
  • Advanced Member
  • Trial users
  • Join Date: 04-Feb 20
  • 105 posts

Posted 25 August 2020 - 07:31 AM #1

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?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21043 posts

Posted 25 August 2020 - 01:52 PM #2

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11791 posts

Posted 25 August 2020 - 08:24 PM #3

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/pr...out.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.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • bebopboy
  • Advanced Member
  • Trial users
  • Join Date: 04-Feb 20
  • 105 posts

Posted 26 August 2020 - 01:38 AM #4

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?



 
  • bebopboy
  • Advanced Member
  • Trial users
  • Join Date: 04-Feb 20
  • 105 posts

Posted 26 August 2020 - 03:14 AM #5

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?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 21043 posts

Posted 26 August 2020 - 06:08 AM #6

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • X-Volution
  • Member
  • Members
  • Join Date: 20-Feb 20
  • 32 posts

Posted 26 August 2020 - 08:32 AM #7

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.



 
  • bebopboy
  • Advanced Member
  • Trial users
  • Join Date: 04-Feb 20
  • 105 posts

Posted 26 August 2020 - 09:36 AM #8

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



 
  • bebopboy
  • Advanced Member
  • Trial users
  • Join Date: 04-Feb 20
  • 105 posts

Posted 26 August 2020 - 09:55 AM #9

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?



 
  • proodie
  • Member
  • Members
  • Join Date: 07-Dec 19
  • 35 posts

Posted 13 September 2020 - 07:16 PM #10

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