Send Order with REST API don't update inventory

vianneyb
New Member
2 0 0

Hi,

i'm struggling with the rest order Api and the inventory management.

When i add an order with the API, i can't find a way to have the stock decrease automatically.

  • I tried a various combinaison of "inventory_behaviour",
  • I checked that the shop is tracking inventory of my product, and set the stock to 100 just to be sure there is enough
  • I tried with other products, same issue
  • If i want to order more than 100, and inventory_behaviour is set on "decrement_ignoring_policy", i have an error from the api: "Unable to reserve inventory"

Here is the payload i send to the API:

 

{
    "inventory_behaviour": "decrement_obeying_policy",
    "source_identifier": 151674585,
    "closed_at": "2020-12-02 15:21:27",
    "created_at": "2020-12-02 15:21:27",
    "updated_at": "2020-12-02 15:21:27",
    "taxes_included": true,
    "send_receipt": false,
    "send_fulfillment_receipt": false,
    "fulfillment_service": "manual",
    "fulfillment_status": "fulfilled",
    "note": "",
    "total_price": 46.45,
    "total_tax": 2.55,
    "currency": "EUR",
    "financial_status": "paid",
    "confirmed": true,
    "source_name": "tiller",
    "line_items": [
        {
            "quantity": 1,
            "variant_id": 32762714947663,
            "requires_shipping": false,
            "tax_lines": [
                {
                    "price": 2.55,
                    "rate": 0.055,
                    "title": "FR TVA"
                }
            ]
        }
    ],
    "transactions": [
        {
            "kind": "sale",
            "status": "success",
            "amount": 49
        }
    ],
    "email": "my@gmail.com",
    "billing_address": {
        "first_name": "tiller",
        "last_name": "tiller",
        "address1": null,
        "city": null,
        "zip": null,
        "country": null
    },
    "shipping_address": {
        "first_name": "tiller",
        "last_name": "tiller",
        "address1": null,
        "city": null,
        "zip": null,
        "country": null
    },
    "customer": {
        "first_name": "tiller",
        "last_name": "tiller",
        "address1": null,
        "city": null,
        "zip": null,
        "country": null
    }
}

 

 

And here is the order in shopify:

{
    "id": 2813850320975,
    "email": "my@gmail.com",
    "closed_at": "2020-12-02T10:26:14-05:00",
    "created_at": "2020-12-02T10:26:17-05:00",
    "updated_at": "2020-12-02T10:26:19-05:00",
    "number": 93,
    "note": "",
    "token": "b8d11e4...b333bc30",
    "gateway": "",
    "test": false,
    "total_price": "49.00",
    "subtotal_price": "49.00",
    "total_weight": 0,
    "total_tax": "2.55",
    "taxes_included": true,
    "currency": "EUR",
    "financial_status": "paid",
    "confirmed": true,
    "total_discounts": "0.00",
    "total_line_items_price": "49.00",
    "cart_token": null,
    "buyer_accepts_marketing": false,
    "name": "#1093",
    "referring_site": null,
    "landing_site": null,
    "cancelled_at": null,
    "cancel_reason": null,
    "total_price_usd": "59.15",
    "checkout_token": null,
    "reference": null,
    "user_id": null,
    "location_id": null,
    "source_identifier": "151674585",
    "source_url": null,
    "processed_at": "2020-12-02T10:26:14-05:00",
    "device_id": null,
    "phone": null,
    "customer_locale": null,
    "app_id": 4553543,
    "browser_ip": null,
    "landing_site_ref": null,
    "order_number": 1093,
    "discount_applications": [],
    "discount_codes": [],
    "note_attributes": [],
    "payment_gateway_names": [
        ""
    ],
    "processing_method": "",
    "checkout_id": null,
    "source_name": "tiller",
    "fulfillment_status": "fulfilled",
    "tax_lines": [
        {
            "price": "2.55",
            "rate": 0.055,
            "title": "FR TVA",
            "price_set": {
                "shop_money": {
                    "amount": "2.55",
                    "currency_code": "EUR"
                },
                "presentment_money": {
                    "amount": "2.55",
                    "currency_code": "EUR"
                }
            }
        }
    ],
    "tags": "",
    "contact_email": "my@gmail.com",
    "order_status_url": "https:\/\/test.myshopify.com\/28548497487\/orders\/b8d11e404050bcb2cee8f8b1b333bc30\/authenticate?key=9ceee4f79b15cfcb9189d89d4fe550d9",
    "presentment_currency": "EUR",
    "total_line_items_price_set": {
        "shop_money": {
            "amount": "49.00",
            "currency_code": "EUR"
        },
        "presentment_money": {
            "amount": "49.00",
            "currency_code": "EUR"
        }
    },
    "total_discounts_set": {
        "shop_money": {
            "amount": "0.00",
            "currency_code": "EUR"
        },
        "presentment_money": {
            "amount": "0.00",
            "currency_code": "EUR"
        }
    },
    "total_shipping_price_set": {
        "shop_money": {
            "amount": "0.00",
            "currency_code": "EUR"
        },
        "presentment_money": {
            "amount": "0.00",
            "currency_code": "EUR"
        }
    },
    "subtotal_price_set": {
        "shop_money": {
            "amount": "49.00",
            "currency_code": "EUR"
        },
        "presentment_money": {
            "amount": "49.00",
            "currency_code": "EUR"
        }
    },
    "total_price_set": {
        "shop_money": {
            "amount": "49.00",
            "currency_code": "EUR"
        },
        "presentment_money": {
            "amount": "49.00",
            "currency_code": "EUR"
        }
    },
    "total_tax_set": {
        "shop_money": {
            "amount": "2.55",
            "currency_code": "EUR"
        },
        "presentment_money": {
            "amount": "2.55",
            "currency_code": "EUR"
        }
    },
    "line_items": [
        {
            "id": 5647526166607,
            "variant_id": 32762714947663,
            "title": "FIGURINE E.T.",
            "quantity": 1,
            "sku": "et-123",
            "variant_title": null,
            "vendor": "shop",
            "fulfillment_service": "manual",
            "product_id": 4839833894991,
            "requires_shipping": false,
            "taxable": true,
            "gift_card": false,
            "name": "FIGURINE E.T.",
            "variant_inventory_management": "shopify",
            "properties": [],
            "product_exists": true,
            "fulfillable_quantity": 0,
            "grams": 300,
            "price": "49.00",
            "total_discount": "0.00",
            "fulfillment_status": "fulfilled",
            "price_set": {
                "shop_money": {
                    "amount": "49.00",
                    "currency_code": "EUR"
                },
                "presentment_money": {
                    "amount": "49.00",
                    "currency_code": "EUR"
                }
            },
            "total_discount_set": {
                "shop_money": {
                    "amount": "0.00",
                    "currency_code": "EUR"
                },
                "presentment_money": {
                    "amount": "0.00",
                    "currency_code": "EUR"
                }
            },
            "discount_allocations": [],
            "duties": [],
            "admin_graphql_api_id": "gid:\/\/shopify\/LineItem\/5647526166607",
            "tax_lines": [
                {
                    "title": "FR TVA",
                    "price": "2.55",
                    "rate": 0.055,
                    "price_set": {
                        "shop_money": {
                            "amount": "2.55",
                            "currency_code": "EUR"
                        },
                        "presentment_money": {
                            "amount": "2.55",
                            "currency_code": "EUR"
                        }
                    }
                }
            ]
        }
    ],
    "fulfillments": [
        {
            "id": 2485797322831,
            "order_id": 2813850320975,
            "status": "success",
            "created_at": "2020-12-02T10:26:19-05:00",
            "service": "manual",
            "updated_at": "2020-12-02T10:26:19-05:00",
            "tracking_company": null,
            "shipment_status": null,
            "location_id": 35542007887,
            "line_items": [
                {
                    "id": 5647526166607,
                    "variant_id": 32762714947663,
                    "title": "FIGURINE E.T.",
                    "quantity": 1,
                    "sku": "et-123",
                    "variant_title": null,
                    "vendor": "shop",
                    "fulfillment_service": "manual",
                    "product_id": 4839833894991,
                    "requires_shipping": false,
                    "taxable": true,
                    "gift_card": false,
                    "name": "FIGURINE E.T.",
                    "variant_inventory_management": "shopify",
                    "properties": [],
                    "product_exists": true,
                    "fulfillable_quantity": 0,
                    "grams": 300,
                    "price": "49.00",
                    "total_discount": "0.00",
                    "fulfillment_status": "fulfilled",
                    "price_set": {
                        "shop_money": {
                            "amount": "49.00",
                            "currency_code": "EUR"
                        },
                        "presentment_money": {
                            "amount": "49.00",
                            "currency_code": "EUR"
                        }
                    },
                    "total_discount_set": {
                        "shop_money": {
                            "amount": "0.00",
                            "currency_code": "EUR"
                        },
                        "presentment_money": {
                            "amount": "0.00",
                            "currency_code": "EUR"
                        }
                    },
                    "discount_allocations": [],
                    "duties": [],
                    "admin_graphql_api_id": "gid:\/\/shopify\/LineItem\/5647526166607",
                    "tax_lines": [
                        {
                            "title": "FR TVA",
                            "price": "2.55",
                            "rate": 0.055,
                            "price_set": {
                                "shop_money": {
                                    "amount": "2.55",
                                    "currency_code": "EUR"
                                },
                                "presentment_money": {
                                    "amount": "2.55",
                                    "currency_code": "EUR"
                                }
                            }
                        }
                    ]
                }
            ],
            "tracking_number": null,
            "tracking_numbers": [],
            "tracking_url": null,
            "tracking_urls": [],
            "receipt": [],
            "name": "#1093.1",
            "admin_graphql_api_id": "gid:\/\/shopify\/Fulfillment\/2485797322831"
        }
    ],
    "refunds": [],
    "total_tip_received": "0.0",
    "original_total_duties_set": null,
    "current_total_duties_set": null,
    "admin_graphql_api_id": "gid:\/\/shopify\/Order\/2813850320975",
    "shipping_lines": [],
    "customer": {
        "id": 3005552820303,
        "email": "my@gmail.com",
        "accepts_marketing": false,
        "created_at": "2020-04-07T07:49:49-04:00",
        "updated_at": "2020-12-02T10:26:19-05:00",
        "first_name": "tiller",
        "last_name": "tiller",
        "orders_count": 21,
        "state": "disabled",
        "total_spent": "747.67",
        "last_order_id": 2813850320975,
        "note": null,
        "verified_email": true,
        "multipass_identifier": null,
        "tax_exempt": false,
        "phone": null,
        "tags": "",
        "last_order_name": "#1093",
        "currency": "EUR",
        "accepts_marketing_updated_at": "2020-04-07T07:49:49-04:00",
        "marketing_opt_in_level": null,
        "tax_exemptions": [],
        "admin_graphql_api_id": "gid:\/\/shopify\/Customer\/3005552820303",
        "default_address": {
            "id": 3767499358287,
            "customer_id": 3005552820303,
            "first_name": "my",
            "last_name": "my",
            "company": null,
            "address1": "1 rue ",
            "address2": "",
            "city": "paris",
            "province": null,
            "country": "France",
            "zip": "7500",
            "phone": null,
            "name": "my my",
            "province_code": null,
            "country_code": "FR",
            "country_name": "France",
            "default": true
        }
    }
}

 

 

I double checked the documentation and this forum for hint, but nothing seems to work.

Do i miss something ??

 

Thx

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 237

Thinking about this, wouldn't the inventory actually be decremented once the order has been fulfilled? I just performed a barebones POST request for a new order for a variant that Shopify tracks inventory quantity. It didn't decrement either. Although I'd imagine if I hit the Fulfillment API endpoint to flag the item as fulfilled then it would decrement the quantity, right?

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 237

Here a screen shot of a barebones new order creation. Where I specify the inventory behavior. I'll include the before and after quantity for the variant. Since I flagged the order as fulfilled, it indeed decremented.

Untitled.pngUntitled2.pngUntitled3.png

0 Likes
vianneyb
New Member
2 0 0

Hi,

thank you for hour answer.

So i tried empiracally to remove one by one the fields of my payload and test for result.

I finally discovered that if i remove "confirmed:true" from my request, it works !

Maybe you can confirm with your example in Postman ?

Anyway it works now.

Thx

0 Likes