Bundles
Limit WPC Product Bundles and WooCommerce Product Bundles bundles by the stock their items share, including variations picked on the bundle page.
Note
This is part of Stockpool Pro.
Bundle plugins check each item on its own. If two items share a pool, that's not enough: a scarf (2 m) and a hat (1 m) from 5 m of linen each look buyable, but only one set fits. Stockpool Pro makes the bundle add its items' pools together.
Supported plugins
- WPC Product Bundles (free and Premium)
- WooCommerce Product Bundles
- Any other, through a filter (see below)
Nothing to set up: link the items to their pools as usual.
What changes
- The bundle's stock status and quantity limit come from all its items' pools together, plus any pool linked to the bundle product itself.
- Adding to the cart is refused when the pools can't cover that many bundles: "not enough stock (1 remaining)".
- Items go into the cart and the order as their own lines, so the cart, checkout and orders count them like any product.
Optional items in WooCommerce Product Bundles only count once the shopper chooses them.
Variations picked on the bundle page
When an item is a variable product, its stock depends on what the shopper picks: a tee in red uses the red pool. The limit follows the pick:
- On a WPC Product Bundles page, as soon as the shopper picks, the quantity limit is worked out again; a combination the pools can't make once disables Add to cart with a notice.
- With either plugin, adding to the cart checks the picked variations.
Other bundle plugins
Developers can tell Stockpool Pro about a bundle's items with the stockpool_bundle_items filter: return a list of items, each with product (a WC_Product), qty (how many in one bundle) and key, or null when the product isn't a bundle.
add_filter( 'stockpool_bundle_items', function ( $items, $bundle ) {
if ( ! $bundle->is_type( 'my_bundle' ) ) {
return $items;
}
$items = array();
foreach ( my_bundle_children( $bundle ) as $key => $child ) {
$items[] = array( 'product' => wc_get_product( $child['id'] ), 'qty' => (float) $child['qty'], 'key' => (string) $key );
}
return $items;
}, 10, 2 );