How To Submit Order Using Api

Hi,

I'm testing CS-Cart's (Multi-Vendor) API using POSTMAN. However, I'm not sure how to submit order by customer although I've read the API documentation at http://docs.cs-cart.com/4.3.x/api/entities/orders.html

Could someone post an example for the body for multiple products? I've managed to complete the auth part. My body content as follows but results in bad request. Please help.

{
    "is_parent_order" : "N",
    "parent_order_id" : "0",
    "payment_id" : "2",
    "products" : {"product_id" : "16"},
    "status" : "O",
    "total" : "2028.00",
    "user_id" : "23"
}

Hi,

I'm testing CS-Cart's API using POSTMAN. However, I'm not sure how to submit the order although I've read the API documentation at http://docs.cs-cart.com/4.3.x/api/entities/orders.html

Could someone post an example for the body for multiple products? I've managed to complete the auth part. My body content as follows but results in bad request. Please help.

{
    "is_parent_order" : "N",
    "parent_order_id" : "0",
    "payment_id" : "2",
    "products" : {"product_id" : "16"},
    "status" : "O",
    "total" : "2028.00",
    "user_id" : "23"
}

Here is the example of the API request creating a new order:

{"order_id":"403-0151016-2545941",
"total":"21.0","payment_id": 2,
"products":{"4163016541":{"product_id":"126","amount":"5"}},
"user_data":{"b_firstname":"Marchand","b_lastname":"Marie-Laure","b_address":"le petit palais","b_zipcode":"22490","b_city":"Plouer Sur Rance","b_country":"","b_phone":"","s_firstname":"Marchand","s_lastname":"Marie-Laure","s_address":"le petit palais","s_zipcode":"22490","s_city":"Plouer Sur Rance","s_country":"FR"}}

Thanks! I'm able to create an order now.

Question 1.

For this line:

"products":{"4163016541":{"product_id":"126","amount":"5"}},

What does "4163016541" means?

Question 2.

I've used /api/auth to verify a customer using an admin and API key. The verification is successful and a key is returned. I've made an order using /api/order but the order shown was made by the admin, not the customer. How do I make an order using API that the issuer is from the customer, not the admin?

Thanks! I'm able to create an order now.

Question 1.

For this line:

"products":{"4163016541":{"product_id":"126","amount":"5"}},

What does "4163016541" means?

This is Item ID, a unique ID of a product added to cart.

Question 2.

I've used /api/auth to verify a customer using an admin and API key. The verification is successful and a key is returned. I've made an order using /api/order but the order shown was made by the admin, not the customer. How do I make an order using API that the issuer is from the customer, not the admin?

Unfortunately, there is no way to display orders made by admin as placed by a customer.

In that case, what's the purpose of /api/auth to verify a customer and gets a key? Isn't that the purpose to uniquely identify a customer so the customer could make orders?

I'm trying to work out how to submit an order for multiple products but to sell those products at a certain price. I'm able to create the order for the single product using the submission below, but the order keeps coming up at $229.95 + Shipping when I want the product to be added at $179.95 with 0 shipping. I've tried using the discount fields etc. on both the product level and the order level and not having any luck.

{"company_id": "1",
"issuer_id":"817",
"total":"179.95",
"subtotal":"179.95",
"discount":"0.00",
"subtotal_discount":"0.00",
"payment_surcharge":"0.00",
"shipping_ids":"6",
"shipping_cost":"0.00",
"status":"E",
"notes":"These are some customer facing notes.",
"user_data":{"user_id":"0",
"firstname":"Billing First",
"lastname":"Billing Last",
"company":"",
"b_firstname":"Billing First",
"b_lastname":"Billing Last",
"b_address":"Billing Address Line 1",
"b_address_2":"Billing Address Line 2",
"b_city":"Billing City",
"b_county":"",
"b_state":"NSW",
"b_country":"AU",
"b_zipcode":"2024",
"b_phone":"0413608353",
"s_firstname":"Billing First",
"s_lastname":"Billing Last",
"s_address":"Billing Address Line 1",
"s_address_2":"Billing Address Line 2",
"s_city":"Billing City",
"s_county":"",
"s_state":"NSW",
"s_country":"AU",
"s_zipcode":"2024",
"s_phone":"0123456789",
"s_address_type":"",
"phone":"0123456789",
"email":"test@testuser.com"},
"payment_id":"12",
"products":{"4163016541": { "product_id":"4839",
"price":"74.95",
"discount":"155.00",
"base_price":229.95,
"original_price":229.95,
"subtotal":74.95,
"display_subtotal":74.95,
"amount":"1"}}

}

I'm trying to work out how to submit an order for multiple products but to sell those products at a certain price. I'm able to create the order for the single product using the submission below, but the order keeps coming up at $229.95 + Shipping when I want the product to be added at $179.95 with 0 shipping. I've tried using the discount fields etc. on both the product level and the order level and not having any luck.

{"company_id": "1",
"issuer_id":"817",
"total":"179.95",
"subtotal":"179.95",
"discount":"0.00",
"subtotal_discount":"0.00",
"payment_surcharge":"0.00",
"shipping_ids":"6",
"shipping_cost":"0.00",
"status":"E",
"notes":"These are some customer facing notes.",
"user_data":{"user_id":"0",
"firstname":"Billing First",
"lastname":"Billing Last",
"company":"",
"b_firstname":"Billing First",
"b_lastname":"Billing Last",
"b_address":"Billing Address Line 1",
"b_address_2":"Billing Address Line 2",
"b_city":"Billing City",
"b_county":"",
"b_state":"NSW",
"b_country":"AU",
"b_zipcode":"2024",
"b_phone":"0413608353",
"s_firstname":"Billing First",
"s_lastname":"Billing Last",
"s_address":"Billing Address Line 1",
"s_address_2":"Billing Address Line 2",
"s_city":"Billing City",
"s_county":"",
"s_state":"NSW",
"s_country":"AU",
"s_zipcode":"2024",
"s_phone":"0123456789",
"s_address_type":"",
"phone":"0123456789",
"email":"test@testuser.com"},
"payment_id":"12",
"products":{"4163016541": { "product_id":"4839",
"price":"74.95",
"discount":"155.00",
"base_price":229.95,
"original_price":229.95,
"subtotal":74.95,
"display_subtotal":74.95,
"amount":"1"}}

}

Please make sure that shipping address is specified properly and check if shipping method is free for this location location. As for discount, please make sure that discount is specified for the order, but not for the product. Also please check if the price is specified correctly. For more information about CS-Cart API, please refer to the following article:

http://docs.cs-cart.com/4.3.x/developer_guide/api/index.html

How is the Item ID generated? I saw some codes in app/functions/fn.cart.php

But I'm not sure how the value gets generated. The variable is $k. Please help.

Please check the fn_generate_cart_id function in the app/functions/fn.cart.php. It takes into account product_id, selected product options and some other extra parameters.

Thanks. The logic is quite complicated. Wonder why CS-Cart developer make it so complicated. Do you think if I use my own logic to generate a random number, will it work as per normal?

Thanks. The logic is quite complicated. Wonder why CS-Cart developer make it so complicated. Do you think if I use my own logic to generate a random number, will it work as per normal?

I think, that it should work. Make some tests and let us know

Hello there,

I'm using REST API to create a front end integrated with cs.cart backend. There're several questions I'd like to ask below:

1. User authentication: how can I validate username/password. I can get an user token using auth but not sure how to validate the password (the get user api doesn't return a password).

2. Shopping cart: looks like I have to manage this cart on our end since the api looks for your native front end.

3. Tax calculation: not sure how to calculate this since the api doesn't provide "tax rates" which is defined in admin.

4. I'd like to get coupons and gift certificates in admin, do you have a rest api for those too?

Appreciate your help.

Khoi