Conditional Logic evaluates the rules configured on a product every time a choice changes, then shows, hides, disables, selects or resets layers and choices accordingly. Everything it exposes is JavaScript — there are no PHP hooks in this add-on.
The actions let you react to what the rules did; the filters let you change how the add-on applies them.
See the hook reference index for how to register JavaScript callbacks.
JavaScript actions
| Hook | Arguments | Purpose |
|---|---|---|
mkl_checked_conditions | (none) | A full evaluation pass has finished |
conditions.set_choice.after | choice | Rules have been re-evaluated after a choice was selected |
mkl_conditions_show_hide_choice | choiceView, show | A choice was shown or hidden by a rule |
mkl_conditions_disabled_choice | choiceView, disabled | A choice was enabled or disabled by a rule |
conditional.selected_layer | layer | A rule opened or selected a layer |
conditional/reset_layer | layer | A Reset action ran on a layer |
conditional/reset_choice | choice, layer | A Reset action ran on a choice or group |
JavaScript filters
| Hook | Arguments | Purpose |
|---|---|---|
mkl_pc_conditionals.proceed | proceed | Whether to apply a condition's actions |
mkl_pc_conditionals.toggle_choices | toggleChoices | Whether hiding a layer also hides its choices |
mkl_pc_conditionals.use_jquery_toggle | useToggle | Whether layers are hidden with jQuery .toggle() |
mkl_pc_conditionals.hide_triggering_layer | true | Whether selecting a layer closes the one clicked |
mkl_checked_conditions
Fires once at the end of every evaluation pass, after all matching rules have been applied. This is the hook to use when you need the settled state — individual show/hide actions fire while the pass is still running, and a later rule may undo what an earlier one did.
wp.hooks.addAction( 'mkl_checked_conditions', 'my-plugin/cl', function () { const visible = PC.fe.layers.filter( ( l ) => false !== l.get( 'cshow' ) ); console.log( 'visible layers:', visible.length );} );
It takes no arguments — read the current state from PC.fe.layers and the choice collections.
mkl_conditions_show_hide_choice and mkl_conditions_disabled_choice
Fire per choice, as the pass applies each rule. Both receive the choice's Backbone view, not
its model — reach the model with view.model.
wp.hooks.addAction( 'mkl_conditions_disabled_choice', 'my-plugin/cl', function ( choiceView, disabled ) { choiceView.$el.attr( 'title', disabled ? 'Not available with your current selection' : '' ); });
mkl_conditions_show_hide_choice is passed show (true when becoming visible);
mkl_conditions_disabled_choice is passed disabled (true when becoming unavailable). Note
that they are opposites of each other, which is easy to get wrong.
conditional/reset_layer and conditional/reset_choice
Fire when a rule's Reset action clears a selection — worth hooking if you keep state of your own alongside the configurator's and need to clear it too.
wp.hooks.addAction( 'conditional/reset_choice', 'my-plugin/cl', function ( choice, layer ) { delete myState[ layer.id ];} );
mkl_pc_conditionals.proceed
Checked for each condition just before its actions run. Return false to skip that condition
entirely — the escape hatch when a rule needs to depend on something the rule builder cannot
express, such as the customer's role or the contents of the cart.
wp.hooks.addFilter( 'mkl_pc_conditionals.proceed', 'my-plugin/cl', function ( proceed ) { return myWholesaleCustomer ? false : proceed;} );
The filter receives only the running proceed value, so it applies to every condition on the
product. To target one rule, gate on state you set elsewhere.
mkl_pc_conditionals.toggle_choices and mkl_pc_conditionals.use_jquery_toggle
Both control how a hidden layer disappears, which matters if your theme animates the configurator or uses CSS rather than inline styles.
toggle_choices defaults to true for top-level layers and false for child layers — hiding a
child layer leaves its choices alone. use_jquery_toggle defaults to true except for step
layers; return false and the add-on only toggles the cshow-hidden class, leaving the
appearance entirely to your CSS:
wp.hooks.addFilter( 'mkl_pc_conditionals.use_jquery_toggle', 'my-plugin/cl', function () { return false; // style .cshow-hidden yourself} );
mkl_pc_conditionals.hide_triggering_layer
When a rule selects or opens a layer, the add-on closes the layer the customer just clicked in,
so the configurator moves the customer along. Return false to leave both open.
wp.hooks.addFilter( 'mkl_pc_conditionals.hide_triggering_layer', 'my-plugin/cl', function () { return false;} );
Core hooks it also fires
PC.fe.configurator.layer_data and PC.fe.configurator.choice_data — see the
Product Configurator JavaScript hooks.