Woocommerce Add To Cart adding whole stock into cart
Im not sure that this will solve your problem in the code, but could be this plugin will do what you trying to do http://woogang.com/product/woocommerce-chained-products-extension/
Im not sure that this will solve your problem in the code, but could be this plugin will do what you trying to do http://woogang.com/product/woocommerce-chained-products-extension/