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
  • 114 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
  • 22270 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 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 12109 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
  • 114 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
  • 114 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
  • 22270 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 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • X-Volution
  • Member
  • Members
  • Join Date: 20-Feb 20
  • 34 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
  • 114 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
  • 114 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
  • 49 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



 
  • mistereri
  • Newbie
  • Members
  • Join Date: 15-Jan 12
  • 9 posts

Posted 04 August 2021 - 12:40 PM #11

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.

 

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.


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

Posted 04 August 2021 - 07:02 PM #12

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]


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.


 
  • mistereri
  • Newbie
  • Members
  • Join Date: 15-Jan 12
  • 9 posts

Posted 05 August 2021 - 04:12 AM #13

 

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 !!!



 
  • mistereri
  • Newbie
  • Members
  • Join Date: 15-Jan 12
  • 9 posts

Posted 05 August 2021 - 10:50 AM #14

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]



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

Posted 05 August 2021 - 08:04 PM #15

Thank you so much it works !!!

Of course it works! :-)


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.


 
  • CBDIT
  • Newbie
  • Members
  • Join Date: 26-Jun 17
  • 7 posts

Posted 08 September 2021 - 07:04 PM #16

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



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

Posted 08 September 2021 - 07:09 PM #17

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.


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.


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

Posted 09 September 2021 - 06:43 AM #18

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. 


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 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • CBDIT
  • Newbie
  • Members
  • Join Date: 26-Jun 17
  • 7 posts

Posted 14 September 2021 - 12:03 AM #19

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



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

Posted 14 September 2021 - 06:35 PM #20

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.


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.