Actions and Filters
WooCommerce Quantity Manager comes with a number of filters which allow you to customize the plugin's behavior.
Please note that these code snippets are aimed at developers. If you feel comfortable using them, our article on how to use code snippets can serve as a helpful guide. However, if you don't feel comfortable using them, then you should ask your developer. If you don't have one then you can use our plugin customization service.
Filters
wc_quantity_manager_handle_add_to_cart_validation
This filter allows you to disable the add to cart validation checks. It uses the same parameters as the WooCommerce core woocommerce_add_to_cart_validation
filter, so you can conditionally disable it as well.
add_filter( 'wc_quantity_manager_handle_add_to_cart_validation', function( $enabled, $product_id, $quantity, $variation_id, $variation ) {
return false;
}, 10, 5 );
wc_quantity_manager_handle_cart_validation
This filter allows you to disable the add to cart validation checks. You can access the global WC()->cart
here if you want to dp this conditionally.
add_filter( 'wc_quantity_manager_handle_cart_validation', function( $enabled ) {
return false;
} );
wc_quantity_manager_default_quantity_rule_value
This filter allows you to modify the calculate rule value for the default quantity.
add_filter( 'wc_quantity_manager_default_quantity_rule_value', function( $rule_value, $rule ) {
return 1;
}, 10, 2 );
wc_quantity_manager_quantity_step_rule_value
This filter allows you to modify the calculate rule value for the quantity step.
add_filter( 'wc_quantity_manager_quantity_step_rule_value', function( $rule_value, $rule ) {
return 1;
}, 10, 2 );
wc_quantity_manager_quantity_rules_rule_value
This filter allows you to modify the calculate rule value for the min and max quantity rules
add_filter( 'wc_quantity_manager_quantity_rules_rule_value', function( $rule_value, $rule ) {
return [
'min' => 1,
'max' => 10,
];
}, 10, 2 );
wc_quantity_manager_values_rules_rule_value
This filter allows you to modify the calculate rule value for the min and max value rules.
add_filter( 'wc_quantity_manager_value_rules_rule_value', function( $rule_value, $rule ) {
return [
'min' => 1.99,
'max' => 10,
];
}, 10, 2 );
wc_quantity_manager_change_default_quantity_input_value
This filter allows you to determine if you want to change the default product quantity input value.
add_filter( 'wc_quantity_manager_change_default_quantity_input_value', function( $change, $product ) {
if ( ! is_cart() ) {
$change = true;
}
return $change;
}, 10, 2 );