Commemorating the Holi Week GOOD FRIDAY SALE - Upto 20% OFF on all addons.

Claim Offer
04Day 05Hr 28Min 04Sec

WCFM Feature Image, Description, Category requirement

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Best Multi Vendor Marketplace Plugin for WordPress Forums WCFM – Ultimate WCFM Feature Image, Description, Category requirement

Viewing 1 reply thread
  • Author
    Posts
    • #20538
      Kevin
      Guest

      Hi 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 );

    • #20553
      WCFM Forum
      Member

      Hi,

      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

Viewing 1 reply thread
  • The topic ‘WCFM Feature Image, Description, Category requirement’ is closed to new replies.