Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Ultimate › Product Custom Validation with product "Parent" and "Child" category
Tagged: product category
- This topic has 12 replies, 2 voices, and was last updated 6 years, 5 months ago by
MOHO.
- AuthorPosts
- August 22, 2018 at 7:52 am #29159
MOHO
ParticipantI 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. - August 22, 2018 at 8:20 am #29168
WCFM Forum
MemberHi,
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
- August 22, 2018 at 8:36 am #29169
MOHO
ParticipantIf need custom fee, please tell me, thanks.
- August 24, 2018 at 2:24 pm #29533
WCFM Forum
MemberHi,
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
- August 24, 2018 at 2:54 pm #29536
- August 24, 2018 at 3:52 pm #29540
WCFM Forum
MemberHi,
I resolved this. You have added that script wrongly, I have fix this.
Kindly take a look.
Thank You
- August 31, 2018 at 10:00 pm #30396
MOHO
ParticipantHi
Where you put?
Could you show me again?thanks.
- September 2, 2018 at 5:33 pm #30529
WCFM Forum
MemberHi,
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
- September 3, 2018 at 5:27 am #30592
- September 5, 2018 at 6:08 am #30815
WCFM Forum
MemberHi,
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
- September 8, 2018 at 6:16 am #31141
MOHO
ParticipantYes it work,
and i see “Please choose a sub-category before submit.”
where could i translate it? - September 11, 2018 at 7:14 am #31288
WCFM Forum
MemberHi,
This text written in that JS code – https://ibb.co/gfCT29
Please change to your language.
Thank You
- September 11, 2018 at 8:15 am #31299
MOHO
ParticipantThanks it work now!
Please close it.
- AuthorPosts
- The topic ‘Product Custom Validation with product "Parent" and "Child" category’ is closed to new replies.