This file contains 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 | |
/** | |
* Custom validation to set minimum number of uploads | |
*/ | |
function prefix_check_minimum_uploads( $passed, $post, $item ) { | |
// Enter the Group ID for the upload field | |
$group_id = 2908; | |
// Enter the Field ID of the upload field | |
$field_id = 2909; | |
// Set the minimum number of uploads required | |
$min_uploads = 3; | |
// Set your message if the user doesn't upload enough files | |
$message = 'Please upload 6 files'; | |
$field_name = 'pewc_group_' . $group_id . '_' . $field_id . '_number_uploads'; | |
if( isset( $post[$field_name] ) && floatval( $post[$field_name] ) < $min_uploads ) { | |
wc_add_notice( $message, 'error' ); | |
$passed = false; | |
} | |
return $passed; | |
} | |
add_filter( 'pewc_filter_validate_cart_item_status', 'prefix_check_minimum_uploads', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment