[5.x]: Stock does not save the first time after creating new product variant
What happened?
Description
When creating a new product variant and directly adding stock to it. It does not save the stock the first time.
Steps to reproduce
- Go to a product
- Click on 'New Product variant'
- Turn on the 'Inventory' switch and directly set the stock to 1
- Click on 'Create product variant'
- There are now changes made in the product entry, so click on 'Save and continue editing'
- After the reload, the stock of the newly created variant is back to 0 again.
Expected behavior
The stock in the newly created variant is saved correctly
Actual behavior
Craft CMS version
5.3.4
Craft Commerce version
5.0.16.1
PHP version
8.3.8
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
@WHITE-developer can you please confirm this is also happening on the latest release of Commerce 5.1.x ?
Hi @lukeholder, thank you for your reply. It looks good in Commerce 5.1.x.
Hi @lukeholder, we checked again and it isn't fixed in the current 5.1.x versions.
We updated to commerce 5.1.3. We created a new product variant and added stock directly to it. The stock was not saved the first time.
Some extra info, Product revisions are disabled, When first creating the variant, and its still a draft the inventory is saved and also visible in the inventory overview and database, but after saving the product itself the inventory item is removed.
I cant reproduce this in any latest release of Commerce 5.x and think it was fixed.
Please raise a new issue if the problem persists. Thanks.