Selling same product in "units" and "pairs"

4 0 1

Hello everyone,

I sell earrings and one of the things that's done by many stores is to sell earrings in pairs or units, as preferred. The thing is Shopify doesn't allow to correlate the stocks, so I need to constantly update stock for my "pair" and "unit" variants. Of course, the way I would like to do it is automatically setting up a system to subtract to a common inventory -1 when I sell a unit and -2 when I sell a pair.

Anyone out there that knows how to do this through code and can guide me maybe? I would highly appreciate it, thanks!