0

I’m creating orders using the Magento 2.3.6 API salesOrderRepositoryV1 interface. Everything seems to work fine except on order lines with a custom option. Custom options are added to the order line and can be returned via an API 'get' call but these options are not displayed when viewed through the website (frontend or admin).

For example, adding a product using the size option ‘medium’. When ordered via the website the option can be seen against then order line.

Using a call to /rest/all/V1/orders/create I add the same option to another order line, but this does not appear on the website.

  "product_option": {
    "extension_attributes": {
      "custom_options": [
        {
          "option_id": "238",
          "option_value": "Medium"
        }
      ]
    }
  }

In this order the first line was added via the website and the second added using Swagger:

website order line view

Looking at the background data the sales_order_item.product_options “info_buyRequest” differs significantly in the option data:

Website Added: "options":{"238":"Medium"},"qty":"1"},"options":[{"label":"Size","value":"Medium","print_value":"Medium","option_id":"238","option_type":"field","option_value":"Medium","custom_view":false}]

API Added: {"qty":"1.0000","options":{"238":"Medium"}}

Adding the addition options information ("options":[{"label":"Size","value":"Medium","print_value":"Medium","option_id":"238","option_type":"field","option_value":"Medium","custom_view":false}]) in the background resolves the issue and the custom option information does then appear on the website, but I can’t find a way to add this data via the API.

My question is, has anybody come across this issue before and found a solution using the API? Thanks for any help you can give.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.