I want to place order on Magento 2.1 using REST API, Please provide me all steps from creating cart to Place order, Actually i need parameters to pass for guest, How i'll set Customer_id etc for guest? Because i am guest how i can have customer id?
1 Answer
First -
POST : /rest/V1/guest-carts
Use the response from this for the following steps.
Second, put an item in the cart using the repsonse -
POST /rest/V1/carts/CARTID/items
{
"cart_item": {
"quote_id": QUOTE ID FROM LAST STEP,
"sku": "TEST",
"qty": 1
}
}
Next, add billing / shipping -
POST /rest/V1/carts/CARTID/billing-address
{
"address": {
"city": "",
"country_id": "",
"company": "",
"email": "",
"firstname": "",
"lastname": "",
"postcode": "",
"region": "",
"saveInAddressBook": ,
"street": [""],
"telephone": ""
},
"useForShipping":
}
POST /rest/V1/carts/CARTID/shipping-information
{
"addressInformation": {
"shippingAddress": {
"region": "",
"region_id": 0,
"country_id": "",
"street": [
""
],
"company": "",
"telephone": "",
"postcode": "",
"city": "",
"firstname": "",
"lastname": "",
"email": "",
"prefix": "",
"region_code": "",
"sameAsBilling":
},
"shipping_method_code": "flatrate",
"shipping_carrier_code": "flatrate"
}
}
Lastly
PUT /rest/V1/carts/CARTID/order
{
"paymentMethod": {
"method": "checkmo"
}
}
More information can be found in the swagger documentation. Try looking at the "quoteGuestCartItemRepository", "quoteGuestCartManagementV1".