Free edition
The free edition applies no filters or actions of its own. It hooks into WooCommerce at three points:
| Hook | What it does |
|---|---|
woocommerce_before_add_to_cart_button |
Prints the contents list. |
woocommerce_add_to_cart_validation |
The stock check (priority 10). |
woocommerce_checkout_create_order_line_item |
Adds the Contains order item meta. |
Data
| What | Where |
|---|---|
| Contents list | Post meta _gmpbf_items on the kit: a list of array( 'id' => int, 'qty' => int ), at most 5 rows, qty 1–99. |
| On the order | Visible order item meta named Contains (translated), e.g. 2 × Glass jar, 1 × Wooden lid. |
| Options, tables, cron | None. |
CSS classes
.gmpbf-contents (the wrapper), .gmpbf-contents-title, .gmpbf-contents-list and .gmpbf-out (the "(out of stock)" note). The free edition ships no storefront stylesheet, so the list takes your theme's styles.
Full edition: filters
All prefixed gmpb_. Arguments are listed in order.
| Filter | Arguments | What it changes |
|---|---|---|
gmpb_bundled_items |
$items, $bundle_id |
The normalized items of a bundle, after loading. |
gmpb_item_priced_individually |
$priced (bool), $item |
Whether one item adds its own price. |
gmpb_item_quantity_min |
$quantity, $item |
An item's minimum quantity. |
gmpb_item_quantity_max |
$max (int or '' for unlimited), $item |
An item's maximum quantity. |
gmpb_item_quantity_default |
$default, $item |
Where an item's quantity field starts. |
gmpb_discount_from_regular |
false, $item |
Return true to take an item's discount off its regular price instead of its current (possibly sale) price. |
gmpb_bundled_item_price |
$price, $product, $item |
The per-unit price of an item after its discount. |
gmpb_bundle_price_range |
$range, $bundle |
The computed minimum and maximum before display. |
gmpb_price_html |
$html, $bundle |
The bundle's price HTML. |
gmpb_empty_price_html |
'', $bundle |
The price HTML of a bundle that cannot be bought. |
gmpb_contents_stock_status |
$status, $bundle |
The contents' stock status. |
gmpb_bundle_stock_quantity |
$quantity, $bundle |
How many whole bundles the contents can supply. |
gmpb_is_in_stock |
$in_stock, $bundle |
Whether the bundle is in stock. |
gmpb_is_editable_in_cart |
$editable, $bundle |
Whether the cart shows an Edit link. |
gmpb_field_prefix |
'', $bundle_id |
A prefix for the form's field names (for several bundles on one page). |
gmpb_form_data |
$data, $bundle |
The data handed to the product page script. |
gmpb_configuration_errors |
$errors, $bundle, $config, $context |
Every message a configuration check produced. Add one to block a configuration. |
gmpb_validation_error_message |
$message, $code, $bundle |
The wording of one refusal. |
gmpb_child_cart_item_data |
$child_data, $item, $cart_item_key |
Data stored on an item's cart line. |
gmpb_child_cart_item_visible |
false, $cart_item |
Show an item's cart line that its settings hide. |
gmpb_child_order_item_visible |
false, $order_item |
Show an item's order line that its settings hide. |
gmpb_settings |
$settings |
The defaults-merged settings. |
gmpb_modules |
$modules |
The module list before registration. |
gmpb_license_api_url, gmpb_update_cache_ttl |
— | The licence API base URL and the update cache lifetime. |
The $code passed to gmpb_validation_error_message is one of missing_item, quantity_min, quantity_max, variation_required, bundle_size, sold_individually, out_of_stock, not_enough_stock or unavailable.
// Make every refusal end with a link to the help page.
add_filter( 'gmpb_validation_error_message', function ( $message, $code, $bundle ) {
return $message . ' <a href="/help/bundles/">Help</a>';
}, 10, 3 );
Full edition: actions
| Action | Arguments | When |
|---|---|---|
gmpb_before_bundled_items |
$bundle |
Before the item list on the product page. |
gmpb_after_bundled_items |
$bundle |
After it. |
gmpb_child_added_to_cart |
$child_key, $parent_key |
An item line was added under a bundle. |
gmpb_child_removed_from_cart |
$child_key, $cart |
An item line was removed with its bundle. |
gmpb_booted |
$container |
The plugin has finished booting. |
Full edition: data
| What | Where |
|---|---|
| Product type | gmpb_bundle |
| Option | gmpb_settings (one key, delete_data, default no), gmpb_reverse_index (which bundles contain which product), gmpb_license |
| Bundle meta | _gmpb_bundled_items, _gmpb_next_item_id, _gmpb_base_price, _gmpb_base_regular_price, _gmpb_base_sale_price, _gmpb_max_raw_price, _gmpb_max_raw_regular_price, _gmpb_layout, _gmpb_group_mode, _gmpb_min_bundle_size, _gmpb_max_bundle_size, _gmpb_edit_in_cart, _gmpb_aggregate_weight |
| Cart item keys | gmpb_config, gmpb_children (on the bundle line), gmpb_parent, gmpb_item_id (on item lines) |
| Order item meta | _gmpb_config, _gmpb_children, _gmpb_cart_key, _gmpb_parent, _gmpb_item_id, _gmpb_group_mode, _gmpb_hidden, _gmpb_price_hidden, _gmpb_needs_shipping, _gmpb_priced_individually (all hidden on the order screen) |
| Query arg | gmpb-update-bundle — the cart key of a line being edited from the cart |
| Object cache group | gmpb_bundles |
| Cron | gmpb_license_check |
The delete-on-uninstall choice is a checkbox on WooCommerce → Bundles license; to set it from code instead:
update_option( 'gmpb_settings', array( 'delete_data' => 'yes' ) );
Full edition: CSS classes
Product page: .gmpb-form with .gmpb-layout-default, .gmpb-layout-tabular or .gmpb-layout-grid; .gmpb-item (and .gmpb-item-optional), .gmpb-item-details, .gmpb-item-title, .gmpb-item-description, .gmpb-item-price, .gmpb-item-variations, .gmpb-quantity, .gmpb-fixed-quantity, .gmpb-unavailable.
Cart: .gmpb-bundle on the bundle row, .gmpb-bundled on item rows, .gmpb-bundled-price, .gmpb-bundled-subtotal, .gmpb-edit-in-cart.
