我正在寻找完整的"快乐的道路"使用Magento2的REST API下订单。到目前为止,这些都是我遵循的所有步骤。我还缺少什么?
创建用户:[POST] /rest/V1/customers
登录(创建令牌):[POST] /rest/V1/integration/customer/token
获取导航产品类别:[GET] /rest/V1/categories
获取产品:
4.1获取类别产品:[GET] /rest/V1/categories/{category_id}/products
4.2或搜索产品:[GET] /rest/V1/products
创建购物车:[POST] /rest/V1/carts/mine
将商品添加到购物车:[POST] /rest/V1/carts/mine/items
获取购物车付款信息[GET] /rest/V1/carts/mine/payment-information
...
下订单还需要做些什么?
答案 0 :(得分:4)
创建空车 网址:http://www.xxxxxx.com/rest/V1/carts/mine 电话:发布 回复:cartID例如:4290
将商品添加到购物车 网址:http://www.xxxxxx.com/rest/V1/carts/mine/items 身体:
{"cartItem":{
"sku":"JFCO00017","qty":1,"name":"Devil May Cry III 3 Dante Cosplay Costume","price":81.55,"product_type":"simple","quote_id":"4290","product_option":{"extension_attributes":{"custom_options":[{"option_id":"thumbnail","option_value":"\/d\/e\/devilmaycryiii3dantecosplay_1_.jpg"},{"option_id":"color_2","option_value":"Red"},{"option_id":"google_size","option_value":"xxs"}]}}}
}
添加结算信息 网址:http://www.xxxxxx.com/rest/V1/carts/mine/billing-address 身体:
{
"address": {
"city": "noida",
"company": "iprag",
"countryId": "IN",
"email": "manish+2@gmail.com",
"firstname": "Manish",
"lastname": "Kumar",
"postcode": "201301",
"region": "UP",
"saveInAddressBook": 1,
"street": ["D-84"],
"telephone": "8802xxxx90"
},
"useForShipping": true
}
获取送货方式 网址:http://www.xxxxxx.com/rest/V1/carts/mine/shipping-methods
{
"carrier_code": "flatrate",
"method_code": "flatrate",
"carrier_title": "Flat Rate",
"method_title": "Fixed",
"amount": 10,
"base_amount": 10,
"available": true,
"error_message": "",
"price_excl_tax": 10,
"price_incl_tax": 10
}
添加送货信息 网址:http://www.xxxxxx.com/rest/V1/carts/mine/shipping-information 体:
{
"addressInformation": {
"billingAddress": {
"city": "noida",
"company": "iprag",
"email": "nkn@gmail.com",
"firstname": "Manish",
"lastname": "Kumar",
"postcode": "335001",
"region": "UP",
"street": ["D-84"],
"telephone": "9413433217"
},
"shippingAddress": {
"city": "noida",
"company": "iprag",
"email": "nkn@gmail.com",
"firstname": "Manish",
"lastname": "Kumar",
"postcode": "335001",
"region": "UP",
"street": ["D-84"],
"telephone": "9413433217"
},
"shippingCarrierCode": "flatrate",
"shippingMethodCode": "flatrate"
}
}
回复:付款方式和购物车详情
订购地点 网址:http://www.xxxxxx.com/rest/V1/carts/mine/order 身体:
{
"paymentMethod":{"method":"checkmo"},
"shippingMethod":
{
"method_code":"flatrate",
"carrier_code":"flatrate",
"additionalProperties":{}
}
}
回复:orderid
答案 1 :(得分:2)
好的,我终于做对了。
[POST] /rest/V1/carts/mine/payment-information