Skip to content

Can anyone please help me to solve the magento 2.4.6 Add Custom Order Attribute To Order API

I have tried to insert additional order attribute through API /rest/V1/orders

I have already created module to insert additional attribute ref taken from https://www.ulmod.com/blog/add-custom-order-attribute-to-magento-2-order-api/

but still the additional data not inserting .
here is my request payload

{
    "entity": {
  "base_currency_code": "USD",
  "base_discount_amount": 0,
  "base_grand_total": 53.71,
  "base_discount_tax_compensation_amount": 0,
  "base_shipping_amount": 5,
  "base_shipping_discount_amount": 0,
  "base_shipping_discount_tax_compensation_amnt": 0,
  "base_shipping_incl_tax": 5,
  "base_shipping_tax_amount": 0,
  "base_subtotal": 45,
  "base_subtotal_incl_tax": 48.71,
  "base_tax_amount": 3.71,
  "base_total_due": 53.71,
  "base_to_global_rate": 1,
  "base_to_order_rate": 1,
  "billing_address_id": 12,
  "created_at": "2019-11-01 09:43:37",
  "customer_dob": "1973-12-15 00:00:00",
  "customer_email": "[email protected]",
  "customer_firstname": "Veronica",
  "customer_gender": 2,
  "customer_group_id": 1,
  "customer_id": 1,
  "customer_is_guest": 0,
  "customer_lastname": "Costello",
  "customer_note_notify": 1,
  "discount_amount": 0,
  "entity_id": 6,
  "global_currency_code": "USD",
  "grand_total": 53.71,
  "discount_tax_compensation_amount": 0,
  "increment_id": "000000006",
  "is_virtual": 0,
  "order_currency_code": "USD",
  "protect_code": "9ecf8fbe586a971550177972c818532e",
  "quote_id": 11,
  "remote_ip": "172.17.0.1",
  "shipping_amount": 5,
  "shipping_description": "Flat Rate - Fixed",
  "shipping_discount_amount": 0,
  "shipping_discount_tax_compensation_amount": 0,
  "shipping_incl_tax": 5,
  "shipping_tax_amount": 0,
  "state": "new",
  "status": "pending",
  "store_currency_code": "USD",
  "store_id": 1,
  "store_name": "Main WebsitenMain Website StorenDefault Store View",
  "store_to_base_rate": 0,
  "store_to_order_rate": 0,
  "subtotal": 45,
  "subtotal_incl_tax": 48.71,
  "tax_amount": 3.71,
  "total_due": 53.71,
  "total_item_count": 1,
  "total_qty_ordered": 1,
  "updated_at": "2019-11-01 09:43:41",
  "weight": 0,
  "items": [
    {
      "amount_refunded": 0,
      "base_amount_refunded": 0,
      "base_discount_amount": 0,
      "base_discount_invoiced": 0,
      "base_discount_tax_compensation_amount": 0,
      "base_original_price": 45,
      "base_price": 45,
      "base_price_incl_tax": 48.71,
      "base_row_invoiced": 0,
      "base_row_total": 45,
      "base_row_total_incl_tax": 48.71,
      "base_tax_amount": 3.71,
      "base_tax_invoiced": 0,
      "created_at": "2019-11-01 09:43:38",
      "discount_amount": 0,
      "discount_invoiced": 0,
      "discount_percent": 0,
      "free_shipping": 0,
      "discount_tax_compensation_amount": 0,
      "is_qty_decimal": 0,
      "is_virtual": 0,
      "item_id": 6,
      "name": "Push It Messenger Bag",
      "no_discount": 0,
      "order_id": 6,
      "original_price": 45,
      "price": 45,
      "price_incl_tax": 48.71,
      "product_id": 14,
      "product_type": "simple",
      "qty_canceled": 0,
      "qty_invoiced": 0,
      "qty_ordered": 1,
      "qty_refunded": 0,
      "qty_shipped": 0,
      "quote_item_id": 21,
      "row_invoiced": 0,
      "row_total": 45,
      "row_total_incl_tax": 48.71,
      "row_weight": 0,
      "sku": "24-WB04",
      "store_id": 1,
      "tax_amount": 3.71,
      "tax_invoiced": 0,
      "tax_percent": 8.25,
      "updated_at": "2019-11-01 09:43:38"
    }
  ],
  "billing_address": {
    "address_type": "billing",
    "city": "Calder",
    "country_id": "US",
    "customer_address_id": 1,
    "email": "[email protected]",
    "entity_id": 12,
    "firstname": "Veronica",
    "lastname": "Costello",
    "parent_id": 6,
    "postcode": "49628-7978",
    "region": "Michigan",
    "region_code": "MI",
    "region_id": 33,
    "street": [
      "6146 Honey Bluff Parkway"
    ],
    "telephone": "(555) 229-3326"
  },
  "payment": {
    "account_status": null,
    "additional_information": [
      "Check / Money order"
    ],
    "amount_ordered": 53.71,
    "base_amount_ordered": 53.71,
    "base_shipping_amount": 5,
    "cc_last4": null,
    "entity_id": 6,
    "method": "checkmo",
    "parent_id": 6,
    "shipping_amount": 5
  },
  "status_histories": [],
  "extension_attributes": {
    "shipping_assignments": [
      {
        "shipping": {
          "address": {
            "address_type": "shipping",
            "city": "Calder",
            "country_id": "US",
            "customer_address_id": 1,
            "email": "[email protected]",
            "entity_id": 11,
            "firstname": "Veronica",
            "lastname": "Costello",
            "parent_id": 6,
            "postcode": "49628-7978",
            "region": "Michigan",
            "region_code": "MI",
            "region_id": 33,
            "street": [
              "6146 Honey Bluff Parkway"
            ],
            "telephone": "(555) 229-3326"
          },
          "method": "flatrate_flatrate",
          "total": {
            "base_shipping_amount": 5,
            "base_shipping_discount_amount": 0,
            "base_shipping_discount_tax_compensation_amnt": 0,
            "base_shipping_incl_tax": 5,
            "base_shipping_tax_amount": 0,
            "shipping_amount": 5,
            "shipping_discount_amount": 0,
            "shipping_discount_tax_compensation_amount": 0,
            "shipping_incl_tax": 5,
            "shipping_tax_amount": 0
          }
        },
        "items": [
          {
            "amount_refunded": 0,
            "base_amount_refunded": 0,
            "base_discount_amount": 0,
            "base_discount_invoiced": 0,
            "base_discount_tax_compensation_amount": 0,
            "base_original_price": 45,
            "base_price": 45,
            "base_price_incl_tax": 48.71,
            "base_row_invoiced": 0,
            "base_row_total": 45,
            "base_row_total_incl_tax": 48.71,
            "base_tax_amount": 3.71,
            "base_tax_invoiced": 0,
            "created_at": "2019-11-01 09:43:38",
            "discount_amount": 0,
            "discount_invoiced": 0,
            "discount_percent": 0,
            "free_shipping": 0,
            "discount_tax_compensation_amount": 0,
            "is_qty_decimal": 0,
            "is_virtual": 0,
            "item_id": 6,
            "name": "Push It Messenger Bag",
            "no_discount": 0,
            "order_id": 6,
            "original_price": 45,
            "price": 45,
            "price_incl_tax": 48.71,
            "product_id": 14,
            "product_type": "simple",
            "qty_canceled": 0,
            "qty_invoiced": 0,
            "qty_ordered": 1,
            "qty_refunded": 0,
            "qty_shipped": 0,
            "quote_item_id": 21,
            "row_invoiced": 0,
            "row_total": 45,
            "row_total_incl_tax": 48.71,
            "row_weight": 0,
            "sku": "24-WB04",
            "store_id": 1,
            "tax_amount": 3.71,
            "tax_invoiced": 0,
            "tax_percent": 8.25,
            "updated_at": "2019-11-01 09:43:38"
          }
        ]
      }
    ],
    "payment_additional_info": [
      {
        "key": "method_title",
        "value": "Check / Money order"
      }
    ],
    "applied_taxes": [
      {
        "code": "US-MI-*-Rate 1",
        "title": "US-MI-*-Rate 1",
        "percent": 8.25,
        "amount": 3.71,
        "base_amount": 3.71
      }
    ],
    "item_applied_taxes": [
      {
        "type": "product",
        "item_id": 6,
        "applied_taxes": [
          {
            "code": "US-MI-*-Rate 1",
            "title": "US-MI-*-Rate 1",
            "percent": 8.25,
            "amount": 3.71,
            "base_amount": 3.71
          }
        ]
      }
    ],
    "converting_from_quote": true,
    "my_custom_order_attribute": "MY CUSTOM ORDER ATTRIBUTE DATA"
  }
}
}