Best Multi Vendor Marketplace Plugin for WordPress › Forums › WCFM – Ultimate › WCFM Feature Image, Description, Category requirement
- This topic has 1 reply, 2 voices, and was last updated 8 years ago by
WCFM Forum.
- AuthorPosts
- March 19, 2018 at 2:43 am #20538
Kevin
GuestHi there,
I received this code previously but my system is telling me that there is an error on line 53. Can I check if everything is as it should be?
START CODE ->
function wcfm_product_manage_custom_validation( $general_fields, $product_id, $product_type ) {
?>
<script>
// WCFM Form Custom Validation
jQuery(document).ready(function($) {
$( document.body ).on( ‘wcfm_form_validate’, function() {
// Featured Image
$featured_img = $(‘#featured_img’).val();
if( !$featured_img ) {
if( $wcfm_is_valid_form )
$(‘#wcfm-main-contentainer .wcfm-message’).html( ‘<span class=”wcicon-status-cancelled”></span>Featured Image: This field is required.’ ).addClass(‘wcfm-error’).slideDown();
else
$(‘#wcfm-main-contentainer .wcfm-message’).append( ‘<span class=”wcicon-status-cancelled”></span>Featured Image: This field is required.’ );$wcfm_is_valid_form = false;
}// Product category
$product_cats = $(‘#product_cats’).val();
if( !$product_cats ) {
if( $wcfm_is_valid_form )
$(‘#wcfm-main-contentainer .wcfm-message’).html( ‘<span class=”wcicon-status-cancelled”></span>Categories: This field is required.’ ).addClass(‘wcfm-error’).slideDown();
else
$(‘#wcfm-main-contentainer .wcfm-message’).append( ‘<span class=”wcicon-status-cancelled”></span>Categories: This field is required.’ );$wcfm_is_valid_form = false;
}// Description
$description = ”;
if( $(‘#description’).hasClass(‘rich_editor’) ) {
if( tinymce.get(‘description’) != null ) {
$description = tinymce.get(‘description’).getContent({format: ‘raw’});
$description = $($description).text();
}
} else {
$description = $.trim($(‘#description’).val());
}
if( !$description ) {
if( $wcfm_is_valid_form )
$(‘#wcfm-main-contentainer .wcfm-message’).html( ‘<span class=”wcicon-status-cancelled”></span>Description: This field is required.’ ).addClass(‘wcfm-error’).slideDown();
else
$(‘#wcfm-main-contentainer .wcfm-message’).append( ‘<span class=”wcicon-status-cancelled”></span>Description: This field is required.’ );$wcfm_is_valid_form = false;
}
});
});
</script>
return $general_fields;
}
add_filter( ‘wcfm_product_manage_fields_general’, ‘wcfm_product_manage_custom_validation’, 50, 3 ); - March 19, 2018 at 3:46 am #20553
WCFM Forum
MemberHi,
This code is right but quotes and many things are changed into HTML characters.
I have corrected those here, try this –
function wcfm_product_manage_custom_validation( $general_fields, $product_id, $product_type ) { ?> <script> // WCFM Form Custom Validation jQuery(document).ready(function($) { $( document.body ).on( 'wcfm_form_validate', function() { // Featured Image $featured_img = $('#featured_img').val(); if( !$featured_img ) { if( $wcfm_is_valid_form ) $('#wcfm-main-contentainer .wcfm-message').html( '<span class="wcicon-status-cancelled"></span>Featured Image: This field is required.' ).addClass('wcfm-error').slideDown(); else $('#wcfm-main-contentainer .wcfm-message').append( '<span class="wcicon-status-cancelled"></span>Featured Image: This field is required.' ); $wcfm_is_valid_form = false; } // Product category $product_cats = $('#product_cats').val(); if( !$product_cats ) { if( $wcfm_is_valid_form ) $('#wcfm-main-contentainer .wcfm-message').html( '<span class="wcicon-status-cancelled"></span>Categories: This field is required.' ).addClass('wcfm-error').slideDown(); else $('#wcfm-main-contentainer .wcfm-message').append( '<span class="wcicon-status-cancelled"></span>Categories: This field is required.' ); $wcfm_is_valid_form = false; } // Description $description = "; if( $('#description').hasClass('rich_editor') ) { if( tinymce.get('description') != null ) { $description = tinymce.get('description').getContent({format: 'raw'}); $description = $($description).text(); } } else { $description = $.trim($('#description').val()); } if( !$description ) { if( $wcfm_is_valid_form ) $('#wcfm-main-contentainer .wcfm-message').html( '<span class="wcicon-status-cancelled"></span>Description: This field is required.' ).addClass('wcfm-error').slideDown(); else $('#wcfm-main-contentainer .wcfm-message').append( '<span class="wcicon-status-cancelled"></span>Description: This field is required.' ); $wcfm_is_valid_form = false; } }); }); </script> return $general_fields; } add_filter( 'wcfm_product_manage_fields_general', 'wcfm_product_manage_custom_validation', 50, 3 );Thank You
- AuthorPosts
- The topic ‘WCFM Feature Image, Description, Category requirement’ is closed to new replies.