Salable quantity not being updated when order is created via V1/orders/create API endpoint
Preconditions and environment
Preconditons
Magento version: 2.4.x
Problem
When creating an order via the V1/orders/create API endpoint, the salable quantity of the products are not being updated. Shipping and invoicing does not help either. I know that I can create orders via the guest cart API, but that has some limitations, and I have to use the Admin API for my integration.
Am I missing something or this is an issue and the salable quantity does not update when using the Admin API to create orders?
Steps to reproduce
- Create an order via the API endpoint V1/orders/create
- Check the salable quantity of the ordered products
- (Optional) Ship and/or invoice the order
Expected result
Salable quantity should update the same way as it does when the order is created via the guest cart API.
Actual result
No error message, but the salable quantity of the products are not being updated. Interesting thing is that the source quantity updates.
Additional information
No response
Release note
No response
Triage and priority
- [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- [x] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Hi @isinkler. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.
- For more details, review the Magento Contributor Assistant documentation.
- Add a comment to assign the issue:
@magento I am working on this - To learn more about issue processing workflow, refer to the Code Contributions.
Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
- [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
- [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- [ ] 3. Add
Area: XXXXXlabel to the ticket, indicating the functional areas it may be related to. - [ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! - [ ] 5. Add label
Issue: Confirmedonce verification is complete. - [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @isinkler ,
Thank you for the report and for your collaboration.
Could you please confirm whether you have followed the steps outlined in the official documentation?
https://developer.adobe.com/commerce/webapi/rest/tutorials/orders/order-create-order/
If possible, please share the endpoint you are using along with the payload. Any additional details or screenshots would also be helpful.
For now, we are marking this issue as "Needs Update".
Thank you!
Hello @engcom-November , thank you for your answer!
We have an integrator system which uses the methods described in the documentation you linked as well. But this "guest-cart" way of creating orders comes with certain limitations, for example creating orders with different currencies or unknown products are not allowed. That's why we started using the "Admin API" endpoint : POST /rest/default/V1/orders and PUT /rest/default/V1/orders.
Here is an example payload:
{
"entity": {
"base_currency_code": "EUR",
"global_currency_code": "EUR",
"order_currency_code": "EUR",
"store_to_base_rate": 0,
"store_to_order_rate": 0,
"base_subtotal": 17619.83,
"tax_amount": 3700.17,
"base_tax_amount": 3700.17,
"customer_email": "[email protected]",
"customer_firstname": "T.",
"customer_is_guest": 1,
"customer_lastname": "Tester",
"shipping_description": "Standard Shipping - Standard Shipping",
"state": "processing",
"status": "processing",
"subtotal": 17619.83,
"grand_total": 21320.00,
"base_grand_total": 21320.00,
"store_id": 2,
"total_paid": 21320.00,
"base_total_paid": 21320.00,
"shipping_amount": 1.00,
"base_shipping_amount": 1.00,
"shipping_tax_amount": 1.00,
"base_shipping_tax_amount": 1.00,
"items": [
{
"name": "test product 3",
"sku": "test-product-3",
"original_price": 1761.98,
"base_original_price": 1761.98,
"price": 1761.98,
"base_price": 1761.98,
"price_incl_tax": 2132.00,
"base_price_incl_tax": 2132.00,
"qty_ordered": 14,
"qty_shipped": 0,
"row_total": 17619.83,
"base_row_total": 17619.83,
"row_total_incl_tax": 21320.00,
"base_row_total_incl_tax": 21320.00,
"tax_amount": 3700.17,
"base_tax_amount": 3700.17,
"tax_percent": 21.00,
"product_id": 20,
"product_type": "simple",
"base_cost": null,
"additional_data": "43"
}
],
"billing_address": {
"company": "",
"firstname": "T.",
"lastname": "Tester",
"street": [
"Teststreet 22"
],
"postcode": "1111 TT",
"city": "Testtown",
"region": "",
"region_code": null,
"country_id": "NL",
"email": "[email protected]",
"telephone": "+31711000000",
"vat_id": null
},
"extension_attributes": {
"shipping_assignments": [
{
"shipping": {
"address": {
"company": "",
"firstname": "T.",
"lastname": "Tester",
"street": [
"Teststreet 22"
],
"postcode": "1111 TT",
"city": "Testtown",
"region": "",
"region_code": null,
"country_id": "NL",
"email": "[email protected]",
"telephone": "+31711000000",
"vat_id": null
},
"method": "standard_shipping"
}
}
]
],
"payment": {
"method": "standard_payment"
},
"status_histories": [
{
"comment": "Order processed successfully - Order No: CE-TEST-18727, Product No: 10265",
"is_customer_notified": 0,
"is_visible_on_front": 0
}
]
}
}
In the example payload, we are placing an order for the product test-product-3, but no matter how many times we do it, the salable quantity is never updated:
When placing an order using the guest-cart method, the Salable Quantity is updating correctly.
Hello @isinkler ,
Thank you for your response.
Could you please confirm whether you meant that the issue is occurring for logged-in customers ?
Thank You!
Hello @isinkler ,
Kindly following up on the above comment.
Thank You!
Hello @engcom-November !
Yes, in order to make calls to the POST /rest/default/V1/orders endpoint, I have to be authenticated.
Thank you!