The add-on turns a layer into one where several choices can be selected at once, and counts those selections against the layer's minimum and maximum. Its own hooks are all about that count.
See the hook reference index for how to register PHP and JavaScript callbacks.
PHP filters
| Hook | Arguments | Purpose |
|---|---|---|
mkl-multiple-choice-styles | $styles | Inline CSS appended to the configurator stylesheet |
JavaScript filters
| Hook | Arguments | Purpose |
|---|---|---|
PC.fe.multiple_choice.item_quantity | quantity, item, choice | How much one selected item counts towards the total |
PC.fe.multiple_choice.items_selected_count | count, selectedChoices, false | The finished count for a layer |
PC.fe.multiple_choice.item_quantity
Every selected item counts as 1 by default. This filter is what makes quantity-aware counting
possible: return the item's quantity and a layer limited to "5 items" becomes a layer limited to
five units.
wp.hooks.addFilter( 'PC.fe.multiple_choice.item_quantity', 'my-plugin/mc', function ( quantity, item, choice ) { return item.qty ? parseInt( item.qty, 10 ) : quantity; });
Return a number. The result is summed across every selected item in the layer.
PC.fe.multiple_choice.items_selected_count
Filters the total once every item has been counted, immediately before it is compared against the layer's minimum and maximum. Use it to exempt certain choices from the limit:
wp.hooks.addFilter( 'PC.fe.multiple_choice.items_selected_count', 'my-plugin/mc', function ( count, selectedChoices ) { const free = selectedChoices.filter( ( c ) => c.is_free ).length; return count - free; });
The third argument is currently always false and is reserved.
mkl-multiple-choice-styles
Inline CSS added after the configurator's own stylesheet. The add-on passes an empty string, so whatever you return is the whole of it.
add_filter( 'mkl-multiple-choice-styles', function ( $styles ) { return $styles . '.mkl_pc_choice.multiple .qty { font-weight: 600; }';} );
Core hooks it also fires
PC.fe.choices.add_one, PC.fe.choices.add_one.after and PC.fe.configurator.layer_data — see
the Product Configurator JavaScript hooks.