VirtueMart Forum

VirtueMart 2 + 3 => Virtuemart Development and bug reports => Topic started by: Dimi on April 06, 2021, 13:42:42 pm

Title: Update parent stock when child is ordered
Post by: Dimi on April 06, 2021, 13:42:42 pm
Hello,
I have an e-shop with clothes. I have created parent products (eg dress) and children products for the different sizes.
I am connecting them with the multi variant custom field.
My problem is that when a child gets ordered, the parent stock is not updated.

eg. The parent has in stock 6 and every child has 2 (3 children). If one of the children is ordered, its stock get decreased but the parent stock is not affected.

I want the parent stock to change every time a child's stock changes. I need it this way because my client wants to check her inventory and know how many products are available.

Versions
Joomla! 3.9.24
VirtueMart 3.6.10 10211
php 7.3


Thank you in advance.
Title: Re: Update parent stock when child is ordered
Post by: GJC Web Design on April 06, 2021, 16:35:56 pm
You would need a plugin to do this...

would need to be written as I know of none available
Title: Re: Update parent stock when child is ordered
Post by: pinochico on April 06, 2021, 17:08:29 pm
Confirm

But because we have import products online from 3 supliers and synchronize stock with ERP online too, then we don't have plugin, but custom solution with OPC from Rupostel call by CLI cron :)
Title: Re: Update parent stock when child is ordered
Post by: Dimi on April 07, 2021, 11:10:25 am
Hello,

Unfortunatelly we can't afford buying a plugin right now, but I am thinking of a workaround.

I am thinking of changing the sql query that updates the child stock to also update the parent stock. Could someone tell me where I can find the sql query that updates the product stock when an item is bought?

Thanks again