Product Custom Validation with product "Parent" and "Child" category

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!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WCFM – Ultimate Product Custom Validation with product "Parent" and "Child" category

Viewing 12 reply threads
  • Author
    Posts
    • #29159
      MOHO
      Participant

      I set product category is required, but i find out some bug
      My product category have “Parent category” and “Child category”

      Clothing (“Parent category”)
      – Children (“Child category”)
      – Men (“Child category”)
      – Shoes (“Child category”)
      – Women (“Child category”)

      When the vendor choose “Clothing”, it will match “required”.
      But i hope the vendor if choose Clothing this “Parent category”, then must choose the one of “Child category” Clothing at least from “Children,Men,Shoes,Women”.

      How could i make it?

      Attachments:
      You must be logged in to view attached files.
    • #29168
      WCFM Forum
      Keymaster

      Hi,

      Well, I understand your requirement.

      But certainly WCFM category rule does not work like this.

      It only checks whether user choose any category or not? Doesn’t matter it’s parent or child! Not even there is any dependency rule.

      I will check how this can be possible to do? Actually, this required some special JS.

      Thank You

    • #29169
      MOHO
      Participant

      If need custom fee, please tell me, thanks.

    • #29533
      WCFM Forum
      Keymaster

      Hi,

      Here is a JavaScript for the purpose, kindly add this in some “.js” of your site -\

      $( document.body ).on( 'wcfm_products_manage_form_validate', function( event, validating_form ) {
      		if( validating_form ) {
      			$form = $(validating_form);
      			$( "#product_cats_checklist > .product_cats_checklist_item" ).each(function() {
      				var count = 0;
      				if ($(this).find('input:checkbox').length > 1) {
      					if ($(this).find('input:checkbox:checked:visible:first').is(':checked')) {
      						$(this).find('input:checkbox:checked:visible:first').parent().parent().find('.product_taxonomy_sub_checklist input:checkbox').each(function() {
      							if ($(this).is(':checked')) {
      								count++;
      							}
      						});
      						if ( !count ) {
      							if( $wcfm_is_valid_form ) 
      								$('#' + $form.attr('id') + ' .wcfm-message').html( '<span class="wcicon-status-cancelled"></span>Please choose a sub-category before submit.').addClass('wcfm-error').slideDown();
      							else
      								$('#' + $form.attr('id') + ' .wcfm-message').append( '<span class="wcicon-status-cancelled"></span>Please choose a sub-category before submit.' );
      							
      							$wcfm_is_valid_form = false;
      							product_form_is_valid = false;
      						}
      					}
      				}
      			});
      		}
      	});

      Thank You

    • #29536
      MOHO
      Participant

      I put into theme js area

      and tick “Parent category” Clothing , and no choose “Child category” , then submit,

      the system didn’t display “product category” must required…

      please check again, thanks.

      Attachments:
      You must be logged in to view attached files.
    • #29540
      WCFM Forum
      Keymaster

      Hi,

      I resolved this. You have added that script wrongly, I have fix this.

      Kindly take a look.

      Thank You

    • #30396
      MOHO
      Participant

      Hi

      Where you put?
      Could you show me again?

      thanks.

    • #30529
      WCFM Forum
      Keymaster

      Hi,

      I have added that JS in addition JavaCcript block – https://ibb.co/dw32aKhttps://ibb.co/dKXFUe

      By mistake you added that at Analytics JS block.

      Thank You

    • #30592
      MOHO
      Participant

      If i put, it will display at footer…

      Attachments:
      You must be logged in to view attached files.
    • #30815
      WCFM Forum
      Keymaster

      Hi,

      Yo have missed script tag –

      Have to wrap this code under <script type="text/javascript"></script> and add there.

      I have just added, now take a look.

      Thank You

    • #31141
      MOHO
      Participant

      Yes it work,

      and i see “Please choose a sub-category before submit.”
      where could i translate it?

    • #31288
      WCFM Forum
      Keymaster

      Hi,

      This text written in that JS code – https://ibb.co/gfCT29

      Please change to your language.

      Thank You

    • #31299
      MOHO
      Participant

      Thanks it work now!

      Please close it.

Viewing 12 reply threads
  • The topic ‘Product Custom Validation with product "Parent" and "Child" category’ is closed to new replies.