I’m trying to make a warehouse for an online store.
Task: The number of items in stock should be updated each time an item is added/removed from the order.
Problem: in the order form, I created a dropdown with products and two buttons “add to order” and “return to stock”. But when the button is pressed, the order has not yet been created and it does not have an ID, so the product cannot be added.
Please let me know if there is a way to achieve this or some other option for solving a warehouse for an eshop.
Thank you in advance.
you can solve the problem by replacing dropdown with link to table. But it’s hard to say. It might be better to send an email to firstname.lastname@example.org with more information about the application.
When you create buttons to add data, our Help Center HERE is very helpful.
With kind regards,
You have to link “Orders” table with “Products” table with many to many. Then you will be able to add products when creating Orders and vice versa.
Then to count how many products is left you have to write a script checking how many orders the product have linked (or maybe another way, it’s up to you).
If you add product to the newly opened order form it has and ID before you save it. It’s stored in: doo.model.id. And when you add any product it should have link with this model even if it’s not created yet.
I hope it will help you.