Нарешті я зрозумів це. Ось що я роблю.
Отримайте єдиний товар
curl -g -X GET "$base_url/index.php/rest/V1/products/24-MB05/" \
-H "Authorization: Bearer $token"
Створити кошик
curl -g -X POST "$base_url/index.php/rest/V1/guest-carts/" \
-H "Authorization: Bearer $token"
Отримати кошик
curl -g -X GET "$base_url/index.php/rest/V1/guest-carts/56241bf6bc084cd7589426c8754fc9c5" \
-H "Authorization: Bearer $token"
Додати товар у кошик
curl -g -X POST "$base_url/index.php/rest/V1/guest-carts/56241bf6bc084cd7589426c8754fc9c5/items" \
-H "Authorization: Bearer $token" \
-H "Content-Type:application/json" \
-d '{ "cartItem": { "quote_id": "56241bf6bc084cd7589426c8754fc9c5", "sku": "24-MB05", "qty": 1 } }'
Додайте інформацію про доставку
curl -g -X POST "$base_url/index.php/rest/V1/guest-carts/56241bf6bc084cd7589426c8754fc9c5/shipping-information" \
-H "Authorization: Bearer $token" \
-H "Content-Type:application/json" \
-d '
{
"addressInformation": {
"shippingAddress": {
"region": "MH",
"region_id": 0,
"country_id": "IN",
"street": [
"Chakala,Kalyan (e)"
],
"company": "abc",
"telephone": "1111111",
"postcode": "12223",
"city": "Mumbai",
"firstname": "Sameer",
"lastname": "Sawant",
"email": "abc@abc.com",
"prefix": "address_",
"region_code": "MH",
"sameAsBilling": 1
},
"billingAddress": {
"region": "MH",
"region_id": 0,
"country_id": "IN",
"street": [
"Chakala,Kalyan (e)"
],
"company": "abc",
"telephone": "1111111",
"postcode": "12223",
"city": "Mumbai",
"firstname": "Sameer",
"lastname": "Sawant",
"email": "abc@abc.com",
"prefix": "address_",
"region_code": "MH"
},
"shipping_method_code": "flatrate",
"shipping_carrier_code": "flatrate"
}
}
'
Отримайте спосіб оплати
curl -g -X GET "$base_url/index.php/rest/V1/guest-carts/56241bf6bc084cd7589426c8754fc9c5/payment-information" \
-H "Authorization: Bearer $token"
Розміщувати замовлення
curl -g -X PUT "$base_url/index.php/rest/V1/guest-carts/56241bf6bc084cd7589426c8754fc9c5/order" \
-H "Authorization: Bearer $token" \
-H "Content-Type:application/json" \
-d '
{
"paymentMethod": {
"method": "checkmo"
}
}'