Cuối cùng tôi đã tìm nó ra. Đây là những gì tôi đang làm.
Nhận một sản phẩm
curl -g -X GET "$base_url/index.php/rest/V1/products/24-MB05/" \
-H "Authorization: Bearer $token"
Tạo giỏ hàng
curl -g -X POST "$base_url/index.php/rest/V1/guest-carts/" \
-H "Authorization: Bearer $token"
Nhận giỏ hàng
curl -g -X GET "$base_url/index.php/rest/V1/guest-carts/56241bf6bc084cd7589426c8754fc9c5" \
-H "Authorization: Bearer $token"
Thêm sản phẩm vào giỏ hàng
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 } }'
Thêm thông tin vận chuyển
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"
}
}
'
Nhận phương thức thanh toán
curl -g -X GET "$base_url/index.php/rest/V1/guest-carts/56241bf6bc084cd7589426c8754fc9c5/payment-information" \
-H "Authorization: Bearer $token"
Đặt hàng
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"
}
}'