Set maximum character limit to Woocommerce product-id (job_description)

Question

I have a listing site where it is possible to limit the minimum and maximum character count for the description field for each of the listing, but not based on the Woocommerce Subscription plan.

Is it possible to limit the character count just for a specific product-id ( subscription package)?

I have this code that sets the minimum character count for the exact field, but I would like to make it maximum and for a specific “product-id”. Can you help?

add_filter( 'submit_job_form_validate_fields', function( $isValid, $fields, $values ) {
$DESCRIPTION_MIN_LENGTH = 200; // Limit description to 200 characters.
foreach ( $fields['job'] as $key => $field ) {
if ( $field['slug'] === 'job_description' && isset( $values['job'][ $field['slug'] ] ) && strlen( $values['job'][ $field['slug'] ] ) < $DESCRIPTION_MIN_LENGTH ) {
return new WP_Error( 'validation-error', sprintf( __( 'Minimum %d characters are required.', 'my-listing' ), $DESCRIPTION_MIN_LENGTH ) );
}
}
return $isValid;
}, 100, 3 ); ```
0
, , , Sanfe 1 year 2020-07-14T06:12:04-05:00 0 Answers 67 views 0

Leave an answer

Browse
Browse