0

I have created Magento rest API for the third party integrations and I have used a couple of API's for listing products, fetching product detail and created order.

I used [PUT] - /V1/orders/create - this API to create order and order was successfully created in Magento admin panel.

My question is whenever we create order it's not affected in product quantity(inventory management).

API - [PUT] - /V1/orders/create

Payload:

{
  "entity": {
    "base_currency_code": "USD",
    "base_discount_amount": 0,
    "base_grand_total": 64,
    "base_shipping_amount": 5,
    "base_shipping_incl_tax": 5,
    "base_shipping_tax_amount": 0,
    "base_shipping_discount_amount": 0,
    "base_subtotal": 59,
    "base_subtotal_incl_tax": 59,
    "base_total_due": 0,
    "base_total_paid" : 64,
    "base_to_global_rate": 0,
    "base_to_order_rate": 0,
    "discount_tax_compensation_amount": 0,
    "base_discount_tax_compensation_amount": 0,
    "shipping_discount_tax_compensation_amount": 0,
    "customer_is_guest": 1,
    "customer_email": "[email protected]",
    "customer_firstname": "Deeban",
    "customer_lastname": "Babu",
    "customer_note_notify": 1,
    "discount_amount": 0,
    "email_sent": 1,
    "global_currency_code": "USD",
    "grand_total": 64,
    "order_currency_code": "USD",
    "shipping_amount": 5,
    "shipping_tax_amount": 0,
    "shipping_description": "Flat Rate - Fixed",
    "shipping_discount_amount": 0,
    "shipping_incl_tax": 5,
    "state": "complete",
    "status": "complete",
    "store_currency_code": "USD",
    "store_to_base_rate": 0,
    "store_to_order_rate": 0,
    "store_id": 1,
    "subtotal": 59,
    "subtotal_incl_tax": 59,
    "total_due": 0,
    "total_paid" : 64,
    "total_item_count": 1,
    "total_qty_ordered": 1,
    "tax_amount": 0,
    "weight": 1,
    "items": [{
      "base_original_price": 59,
      "base_price": 59,
      "base_price_incl_tax": 59,
      "base_row_total": 59,
      "base_row_total_incl_tax": 59,
      "name": "Fusion Backpack",
      "original_price": 59,
      "price": 59,
      "price_incl_tax": 59,
      "product_id": 6,
      "product_type": "simple",
      "qty_ordered": 1,
      "row_total": 59,
      "row_total_incl_tax": 59,
      "sku": "24-MB02",
      "store_id": 1,
      "weight": 1
    }],
    "billing_address": {
      "address_type": "billing",
      "city": "Chennai ",
      "company": "",
      "country_id": "IN",
      "customer_address_id": 0,
      "email": "[email protected]",
      "firstname": "deeban",
      "lastname": "babu",
      "postcode": "600041",
      "region": "TN",
      "street": ["chennai"],
      "telephone": "9043202246"
    },
    "payment": {
      "amount_ordered": 64,
      "amount_paid":64,
      "base_amount_ordered": 64,
      "base_amount_paid" : 64,
      "base_shipping_amount": 5,
      "method": "checkmo",
      "shipping_amount": 5
    },
    "status_histories": [{
      "comment" : "new order",
      "status": "complete"
    }],
    "extension_attributes": {
      "shipping_assignments": [{
        "shipping": {
          "address": {
            "address_type": "shipping",
            "city": "Chennai",
            "company": "",
            "country_id": "IN",
            "customer_address_id": 0,
            "email": "[email protected]",
            "firstname": "deeban",
            "lastname": "babu",
            "postcode": "600041",
            "region": "TN",
            "street": ["chennai"],
            "telephone": "9043202246"
          },
          "method": "flatrate_flatrate",
          "total": {
            "base_shipping_amount": 5,
            "base_shipping_incl_tax": 5,
            "shipping_amount": 5,
            "shipping_incl_tax": 5
          },
          "extension_attributes": []
        },

        "extension_attributes": []
      }],
      "applied_taxes": [],
      "item_applied_taxes": [],
      "converting_from_quote": false
    }
  }
}

Response:

{
    "base_currency_code": "USD",
    "base_discount_amount": 0,
    "base_grand_total": 64,
    "base_discount_tax_compensation_amount": 0,
    "base_shipping_amount": 5,
    "base_shipping_discount_amount": 0,
    "base_shipping_incl_tax": 5,
    "base_shipping_tax_amount": 0,
    "base_subtotal": 59,
    "base_subtotal_incl_tax": 59,
    "base_total_due": 0,
    "base_total_paid": 64,
    "base_to_global_rate": 0,
    "base_to_order_rate": 0,
    "billing_address_id": 34,
    "created_at": "2019-04-01 09:23:38",
    "customer_email": "[email protected]",
    "customer_firstname": "Deeban",
    "customer_is_guest": 1,
    "customer_lastname": "Babu",
    "customer_note_notify": 1,
    "discount_amount": 0,
    "email_sent": 1,
    "entity_id": 22,
    "global_currency_code": "USD",
    "grand_total": 64,
    "discount_tax_compensation_amount": 0,
    "increment_id": "000000030",
    "order_currency_code": "USD",
    "protect_code": "855f88ee22e98a9441df11594c801f7d",
    "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": "complete",
    "status": "complete",
    "store_currency_code": "USD",
    "store_id": 1,
    "store_name": "Main Website\nMain Website Store\nDefault Store View",
    "store_to_base_rate": 0,
    "store_to_order_rate": 0,
    "subtotal": 59,
    "subtotal_incl_tax": 59,
    "tax_amount": 0,
    "total_due": 0,
    "total_item_count": 1,
    "total_paid": 64,
    "total_qty_ordered": 1,
    "updated_at": "2019-04-01 09:23:38",
    "weight": 1,
    "items": [
        {
            "base_original_price": 59,
            "base_price": 59,
            "base_price_incl_tax": 59,
            "base_row_total": 59,
            "base_row_total_incl_tax": 59,
            "created_at": "2019-04-01 09:23:38",
            "item_id": 20,
            "name": "Fusion Backpack",
            "order_id": 22,
            "original_price": 59,
            "price": 59,
            "price_incl_tax": 59,
            "product_id": 6,
            "product_type": "simple",
            "qty_ordered": 1,
            "row_total": 59,
            "row_total_incl_tax": 59,
            "sku": "24-MB02",
            "store_id": 1,
            "updated_at": "2019-04-01 09:23:38",
            "weight": 1
        }
    ],
    "billing_address": {
        "address_type": "billing",
        "city": "Chennai ",
        "company": "",
        "country_id": "IN",
        "customer_address_id": 0,
        "email": "[email protected]",
        "entity_id": 34,
        "firstname": "deeban",
        "lastname": "babu",
        "parent_id": 22,
        "postcode": "600041",
        "region": "TN",
        "region_code": "TN",
        "street": [
            "chennai"
        ],
        "telephone": "9043202246"
    },
    "payment": {
        "account_status": null,
        "additional_information": [],
        "amount_ordered": 64,
        "amount_paid": 64,
        "base_amount_ordered": 64,
        "base_amount_paid": 64,
        "base_shipping_amount": 5,
        "cc_last4": null,
        "entity_id": 20,
        "method": "checkmo",
        "parent_id": 22,
        "shipping_amount": 5
    },
    "status_histories": [
        {
            "comment": "new order",
            "entity_id": 5,
            "is_customer_notified": null,
            "is_visible_on_front": null,
            "parent_id": 22,
            "status": "complete"
        }
    ],
    "extension_attributes": {
        "shipping_assignments": [
            {
                "shipping": {
                    "address": {
                        "address_type": "shipping",
                        "city": "Chennai",
                        "company": "",
                        "country_id": "IN",
                        "customer_address_id": 0,
                        "email": "[email protected]",
                        "entity_id": 35,
                        "firstname": "deeban",
                        "lastname": "babu",
                        "parent_id": 22,
                        "postcode": "600041",
                        "region": "TN",
                        "region_code": "TN",
                        "street": [
                            "chennai"
                        ],
                        "telephone": "9043202246"
                    },
                    "method": "flatrate_flatrate",
                    "total": {
                        "base_shipping_amount": 5,
                        "base_shipping_incl_tax": 5,
                        "shipping_amount": 5,
                        "shipping_incl_tax": 5
                    }
                },
                "items": null
            }
        ],
        "applied_taxes": [],
        "item_applied_taxes": [],
        "converting_from_quote": false
    }
}

1 Answer 1

0

I believe this documentation "Order Processing with Inventory Management" via REST endpoints would be helpful to you https://devdocs.magento.com/guides/v2.3/rest/tutorials/inventory/

Looks like you need to pay attention to Step 11 and 12 (https://devdocs.magento.com/guides/v2.3/rest/tutorials/inventory/run-ssa.html and https://devdocs.magento.com/guides/v2.3/rest/tutorials/inventory/create-shipment.html)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.