View Categories

Conditional Shipping: Developer Hooks and Filters Reference

Developer Hooks and Filters Reference #

Conditional Shipping for WooCommerce: Restrict Shipping Options by Anything exposes a small set of WooCommerce conditional shipping hooks and filters so you can change how conditions are evaluated and how notices are rendered without editing the plugin files. This page lists every filter and action the plugin fires, with its arguments and what it controls.

All settings referenced below live under WPFactory > Conditional Shipping (also reachable at WooCommerce > Settings > Conditional Shipping).

Filters #

Filter Arguments What it does
alg_wc_cond_shipping_logical_operator $logical_operator, $rate, $package Changes the AND / OR logical operator at runtime, for example per rate. Return 'AND' or 'OR'.
alg_wc_cond_shipping_method_id $rate->method_id, $rate The method id used to look up a condition’s stored value for a rate. Pro uses this to switch to per-instance ids.
alg_wc_cond_shipping_settings_shipping_methods $shipping_methods The list of shipping methods shown in the settings. Pro swaps in per-instance methods.
alg_wc_cond_shipping_settings_method_id $method_id, $method The method id used on the settings screen.
alg_wc_cond_shipping_settings_method_title $method_title, $method The method title shown on the settings screen.
alg_wc_cond_shipping_settings varies Internal Pro gate filter, returns '' in Pro to unlock the “Use shipping instances” option. Not generally useful to site developers.
alg_wc_conditional_shipping_notice_hooks array of hook names Controls where the per-condition “Additional notice” is printed. Default array( 'woocommerce_before_cart', 'woocommerce_before_checkout_form' ).

Actions #

Action Arguments Fires when
alg_wc_cond_shipping_core_loaded $core The core class is constructed. $core is the plugin core instance.

Option key prefixes #

Most option keys use the prefix wpjup_wc_cond_shipping_. Two use alg_wc_cond_shipping_ instead: the Logical operator option (alg_wc_cond_shipping_logical_operator) and the settings tab id (alg_wc_cond_shipping). This mismatch is real, so when you read options directly with get_option() you must use the exact key. For example the Debug option is wpjup_wc_cond_shipping_debug, but the operator is alg_wc_cond_shipping_logical_operator.

The plugin text domain is conditional-shipping-for-woocommerce, and the main instance function is alg_wc_cond_shipping(), which returns the plugin object.

Example: switch AND / OR per rate #

By default the plugin combines multiple enabled conditions with the global Logical operator option. Use alg_wc_cond_shipping_logical_operator to override it for a single rate, for example to make one method OR while the rest stay AND.

add_filter( 'alg_wc_cond_shipping_logical_operator', function ( $logical_operator, $rate, $package ) {
    if ( 'flat_rate:3' === $rate->id ) {
        return 'OR';
    }
    return $logical_operator;
}, 10, 3 );

Example: change where the Additional notice prints #

The per-condition “Additional notice” is printed on the cart and checkout pages using the hooks returned by alg_wc_conditional_shipping_notice_hooks. Return your own list of hook names to move it, for example to show it inside the cart totals as well.

add_filter( 'alg_wc_conditional_shipping_notice_hooks', function ( $hooks ) {
    $hooks[] = 'woocommerce_after_cart_table';
    return $hooks;
} );

Need a hand? Our team answers every ticket on the Conditional Shipping support forum.