The free edition applies no filters of its own. The filters, actions and the shortcode below are the full edition's. Storage, cart keys and CSS classes are shared by both.
Filters — Full edition
gmbt_set
apply_filters( 'gmbt_set', array $set, int $product_id ) — one product's resolved set, after every unbuyable companion has been dropped. $set has:
product_id(int) — the product the box belongs to (a variation resolves to its parent),items(WC_Product[]) — the companions, in order,discount(none,percentorfixed),amount(float).
Return null, or an array with empty items, to take the box off that product. The same set is used by the box, the add endpoint and the discount, so a change here applies to all three.
gmbt_rules
apply_filters( 'gmbt_rules', array $rules ) — the category rules as read, each array( 'terms' => int[], 'items' => int[], 'discount' => string, 'amount' => float ).
gmbt_settings
apply_filters( 'gmbt_settings', array $settings ) — the merged box settings (enabled, title, button_text, show_images).
gmbt_modules, gmbt_license_api_url, gmbt_update_cache_ttl
The module list the plugin boots; the gatemi.com licensing endpoint; how long the update payload is cached, in seconds.
Shortcode — Full edition
[gatemi_bought_together]
[gatemi_bought_together product="123"]
Without product, it uses the current global product. It renders nothing when the product has no box.
AJAX endpoints
| Edition | Action | Nonce action |
|---|---|---|
| Free | gmbtf_add |
gmbtf_add |
| Full | gmbt_add |
gmbt_add |
Registered on wc_ajax_{action} (the endpoint the script uses), and on wp_ajax_ / wp_ajax_nopriv_. POST fields: nonce, product (the box's product id), items[] (ticked ids). The JSON response has ok, message, and on success added, fragments (and, in the full edition, refused — the ids that could not be added).
Storage
| What | Where | Edition |
|---|---|---|
| Box settings | option gmbt_settings |
both |
| Category rules | option gmbt_rules |
full |
| Licence | option gmbt_license, transient gmbt_update_payload |
full |
| Companions | product meta _gmbt_items (array of ids) |
both |
| No box on this product | product meta _gmbt_disabled = yes |
both |
| Set discount kind | product meta _gmbt_discount |
full |
| Set discount amount | product meta _gmbt_amount |
full |
No database tables.
Cart and order data
- Cart item key
gmbt_set— the box's product id, on every line the button added. - Cart item key
gmbt_base— Full edition, the price the line came in at. - Order item meta
_gmbt_set— the box's product id. - Order item meta
_gmbt_discount— Full edition, the per-unit amount taken off, when a discount applied.
Lines show Bought together: Part of a set through woocommerce_get_item_data.
Hooks the plugin uses
woocommerce_after_single_product_summary(priority 15) — prints the box.woocommerce_before_calculate_totals(priority 20) — Full edition, prices the set.woocommerce_checkout_create_order_line_item— writes the order meta.woocommerce_product_data_tabs,woocommerce_product_data_panels,woocommerce_process_product_meta— the Bought together tab.
To move the box, remove the action and add it somewhere else. In the free edition:
add_action( 'init', function () {
remove_action( 'woocommerce_after_single_product_summary', array( 'GMBTF_Frontend', 'render_on_product' ), 15 );
add_action( 'woocommerce_after_single_product_summary', array( 'GMBTF_Frontend', 'render_on_product' ), 25 );
}, 20 );
In the full edition, use the shortcode or gmbt_set instead.
Example: no box on products in the "Gift cards" category
// Full edition only.
add_filter( 'gmbt_set', function ( $set, $product_id ) {
return has_term( 'gift-cards', 'product_cat', $product_id ) ? null : $set;
}, 10, 2 );
CSS classes
| Class | Element |
|---|---|
.gmbt |
The box |
.gmbt-title |
The heading |
.gmbt-items, .gmbt-item, .gmbt-item--main |
The list and its rows |
.gmbt-check |
Each checkbox |
.gmbt-item-image, .gmbt-item-name, .gmbt-item-price |
Row parts |
.gmbt-total, .gmbt-total-value |
The running total |
.gmbt-saving |
Full edition: the saving line |
.gmbt-add |
The button (also .button; in the free edition also .wp-element-button, so a block theme styles it) |
.gmbt-message |
The status message under the button |
The stylesheet (handle gmbtf in the free edition, gmbt in the full edition) is enqueued in the footer only on pages where a box was drawn.
