Hi @arnelo ,
The Material Manager app can do this. It allows you to track the inventory of raw materials that you use to sell your finished products well keeping all the inventory in sync.
In your case you would enter a raw material for your 2g unit. Then you would link each of the actual products you sell specifying how much of that unit is needed to sell the finished product. It will then work as you described, you sell the 10g unit which will draw down 5 x 2g units from your raw material inventory. It will then also sync your Shopify inventory calculating how many of each product you can sell with the remaining material inventory.