woocommerce / woocommerce-rest-api

This is the WooCommerce core REST API Package. It runs standalone as a feature plugin too.
71 stars 46 forks source link

POST /v2/orders or v3/orders does not handle instance_id according to schema #53

Closed hedqvist closed 4 years ago

hedqvist commented 4 years ago

Describe the bug In the documentation for the rest endpoints: POST v2/orders or POST v3/orders

The property "instance_id" is displayed as an property that could be posted. https://ibb.co/jWTz3t5

Example on posted data if we post like documentation says:

"shipping_lines": [
    {
      "method_title": "Postage",
      "method_id": "flat_rate",
      "instance_id": "1",
      "total": "23.20",
      "total_tax": "5.80"
    }
  ],

Response from API:

    {
      "id": 60657,
      "method_title": "Postage",
      "method_id": "flat_rate",
      "instance_id": "",
      "total": "23.20",
      "total_tax": "5.80",
      "taxes": [
        {
          "id": 1,
          "total": "5.8",
          "subtotal": ""
        }
      ],
      "meta_data": [

      ]
    }
  ]

Instead if we post instance_id in meta_data:

"shipping_lines": [
  {
    "method_title": "Postage",
    "method_id": "flat_rate",
    "total": "23.20",
    "total_tax": "5.80",
    "meta_data": [
      {
        "key": "instance_id",
        "value": "1"
      }
    ]
  }
],

Reponse:

"shipping_lines": [
        {
            "id": 1645,
            "method_title": "Postage",
            "method_id": "flat_rate",
            "instance_id": "1",
            "total": "23.20",
            "total_tax": "5.80",
            "taxes": [
                {
                    "id": 1,
                    "total": "5.8",
                    "subtotal": ""
                }
            ],
            "meta_data": []
        }
    ],

To Reproduce

Screenshots https://ibb.co/jWTz3t5

Expected behavior A clear and concise description of what you expected to happen.

Isolating the problem (mark completed items with an [x]):

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label type: bug to this issue, with a confidence of 0.91. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

juliaamosova commented 4 years ago

Thanks for reporting the issue @hedqvist. I can reproduce it on my end.

POST Request as-is - instance_id doesn't get updated - it stays the same on my end (unlike in your example where it becomes empty):

api1

POST Request posting instance_id via meta_data - instance_id gets updated:

api2

claudiosanches commented 4 years ago

Thank you for reporting this issue!

I'm closing the issue as it already has a PR, please continue the discussion over at #85.