Magento 2 Rest api to create order not adding shipping address

最后都变了- 提交于 2019-12-23 02:23:08

问题


I am trying to create an order using magento 2 rest api.But the shipping address is not adding with order details.Because of no shipping address the order is in incomplete format

http://127.0.0.1/netmeds_mage/rest/V1/orders/create

Method : PUT

This is the json request :

{"entity":{"base_currency_code":"INR","base_discount_amount":0,"base_grand_total":38,"base_shipping_amount":5,"base_shipping_incl_tax":5,"base_shipping_tax_amount":0,"base_shipping_discount_amount":0,"base_subtotal":33,"base_subtotal_incl_tax":33,"base_total_due":38,"base_to_global_rate":1,"base_to_order_rate":1,"discount_tax_compensation_amount":0,"base_discount_tax_compensation_amount":0,"shipping_discount_tax_compensation_amount":0,"customer_is_guest":0,"customer_dob":"Jan 18, 1987","customer_email":"sharvesh@gmail.com","customer_firstname":"Sharvesh","customer_gender":1,"customer_group_id":1,"customer_id":4,"customer_lastname":"CP","customer_note_notify":1,"discount_amount":0,"email_sent":1,"global_currency_code":"INR","grand_total":38,"order_currency_code":"INR","remote_ip":"127.0.0.1","shipping_amount":5,"shipping_tax_amount":0,"shipping_description":"Flat Rate - Fixed","shipping_discount_amount":0,"shipping_incl_tax":5,"state":"pending","status":"pending","store_currency_code":"INR","store_to_base_rate":0,"store_to_order_rate":0,"store_id":1,"subtotal":33,"subtotal_incl_tax":33,"total_due":38,"total_item_count":1,"total_qty_ordered":1,"tax_amount":0,"weight":1,"items":[{"base_original_price":33,"base_price":33,"base_price_incl_tax":33,"base_row_total":33,"base_row_total_incl_tax":33,"name":"Endeavor Daytrip Backpack","original_price":33,"price":33,"price_incl_tax":33,"product_id":11,"product_type":"simple","qty_ordered":1,"row_total":33,"row_total_incl_tax":33,"sku":"24-WB06","store_id":1,"weight":1}],"billing_address":{"address_type":"billing","city":"Chennai","company":"Netmeds","country_id":"IN","customer_address_id":4,"email":"sharvesh@gmail.com","firstname":"Sharvesh","lastname":"C","postcode":"600117","region":"Tamilnadu","street":["6A,4th street,Keelkattalai"],"telephone":"9840626148"},"payment":{"amount_ordered":38,"base_amount_ordered":38,"base_shipping_amount":5,"method":"checkmo","shipping_amount":5},"status_histories":[],"extension_attributes":{"shipping_assignments":[{"shipping":{"address":{"address_type":"shipping","city":"Chennai","company":"Netmeds","country_id":"IN","customer_address_id":4,"email":"sharvesh@gmail.com","firstname":"Sharvesh","lastname":"C","postcode":"600117","region":"Tamilnadu","street":["6A,4th street,Keelkattalai"],"telephone":"9840626148"},"method":"flatrate_flatrate","total":{"base_shipping_amount":5,"base_shipping_incl_tax":5,"shipping_amount":5,"shipping_incl_tax":5},"extension_attributes":[]},"items":[{"base_original_price":33,"base_price":33,"base_price_incl_tax":33,"base_row_total":33,"name":"Endeavor Daytrip Backpack","original_price":33,"price":33,"price_incl_tax":33,"product_id":11,"product_type":"simple","qty_ordered":1,"row_total":33,"row_total_incl_tax":33,"sku":"24-WB06","store_id":1,"weight":1}],"extension_attributes":[]}],"applied_taxes":[],"item_applied_taxes":[],"converting_from_quote":true}}}

Tell me whether am missing anything or i need to add anything.


回答1:


according the model scheme (http://devdocs.magento.com/swagger/) you do miss some parameters, I would try to start with this :

"shipping": {
  "address": {
    "address_type": "string",
    "city": "string",
    "company": "string",
    "country_id": "string",
    "customer_address_id": 0,
    "customer_id": 0,
    "email": "string",
    "entity_id": 0,
    "fax": "string",
    "firstname": "string",
    "lastname": "string",
    "middlename": "string",
    "parent_id": 0,
    "postcode": "string",
    "prefix": "string",
    "region": "string",
    "region_code": "string",
    "region_id": 0,
    "street": [
      "string"
    ],
    "suffix": "string",
    "telephone": "string",
    "vat_id": "string",
    "vat_is_valid": 0,
    "vat_request_date": "string",
    "vat_request_id": "string",
    "vat_request_success": 0,
    "extension_attributes": {}
  },


来源:https://stackoverflow.com/questions/42201253/magento-2-rest-api-to-create-order-not-adding-shipping-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!