I have a few composite products on my webshop which is based on Woocommerce, but I only get the number of items in stock from the main product to be displayed.
For example I have 2 different couches on which the same type of pillow fits. If I want my stock to be adjusted correctly I need to make a composite product so the stock goes down on that pillow type wether they choose couch one or 2... (different than when you use variable products because then only the stock of that variation on that product goes down).
I've tried this code:
I've already tried to get data out of the database myself and tried contacting the developer of the plugin but they can't help me so I used the code below in hopes of fixing my problem, but that doesn't work. (it only shows the stock of the main product)
add_action('woocommerce_after_shop_loop_item','bbloomer_show_stock_shop',
10);
function bbloomer_show_stock_shop() {
global $product;
if ( $product->stock ) { // if manage stock is enabled
if ( number_format( $product->stock,0,'','' ) < 3 ) { // if stock is low
echo '<div class="remaining">Only ' . number_format($product->stock,0,'','') . ' left in stock!</div>';
} else {
echo '<div class="remaining">' . number_format($product->stock,0,'','') . ' left in stock</div>';
}
}
}
Here you can see an example: http://karup.qubeli.be/index.php/product/test-slaapbank/
I want the nr of stock of each option to be displayed (the options are stored as a variable product and yes the nr of stock of each variation is set).
So for example "5 in stock" below each option.