Created
October 7, 2023 05:08
-
-
Save codersaiful/0814c9ce37b848db7ce3ea57507cda3a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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