Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save codersaiful/0814c9ce37b848db7ce3ea57507cda3a to your computer and use it in GitHub Desktop.
Save codersaiful/0814c9ce37b848db7ce3ea57507cda3a to your computer and use it in GitHub Desktop.
<?php
/**
* Disable min max for specific condition
*
* @author Saiful Islam <[email protected]>
*/
add_filter('wcmmq_single_product_min_max_condition','wcmmq_custom_min_max_control');
add_filter('wcmmq_add_validation_check','wcmmq_custom_validation_bool');
add_filter('wcmmq_cart_validation_check','wcmmq_custom_validation_bool');
function wcmmq_custom_min_max_control( $args ){
if( wc_current_user_has_role('administrator') || wc_current_user_has_role('shop_manager') ){
$args['max_value'] = -1;
$args['min_value'] = 1;
$args['step'] = 1;
if( ! is_cart() ){
$args['input_value'] = 1;
}
return $args;
}
return $args;
}
function wcmmq_custom_validation_bool(){
if( wc_current_user_has_role('administrator') || wc_current_user_has_role('shop_manager') ){
return false;
}else{
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment