Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Ultimate › Product Custom Validation not working with snippet
- This topic has 18 replies, 2 voices, and was last updated 4 years, 6 months ago by Sushobhan.
- AuthorPosts
- May 13, 2020 at 10:22 am #130305HenrietteParticipant
Hi,
On Admin Dashboard in Product Custom validation I made required:
Price
Featured Image
CategoriesBut when vendor adds a product without filling in any fields only error messages are showing for:
Price
Product Title
Featured ImageThe category part has a required asterix but vendor can still add product without choosing a category.
I think this is because of a snippet I used from this forum to restrict vendor to add a product in the main category (which works very well by the way).
When I remove the snippet from my child theme’s functions.php the message of required category is visible when vendor tries to publish his product.The snippet I used:
// Main category restriction function wcfm_pm_custom_script( $end_point ) { switch( $end_point ) { case 'wcfm-products-manage': ?> <script> jQuery(document).ready(function($) { $('#product_cats_checklist').children('.product_cats_checklist_item').each(function() { if( $(this).children('.product_taxonomy_sub_checklist').length > 0 ) { $(this).children('label').children('input').addClass('wcfm_custom_hide'); } }); }); </script> <?php break; } } add_action( 'after_wcfm_load_views', 'wcfm_pm_custom_script' );
Is there any way I can keep this snippet but with the required category choosing message when vendor forgets to pick a category?
Thank you!
- May 15, 2020 at 5:55 pm #131386HenrietteParticipant
Anyone?
- May 15, 2020 at 11:07 pm #131503SushobhanKeymaster
Hi,
Please use the following snippet-function wcfm_pm_custom_script( $end_point ) { switch( $end_point ) { case 'wcfm-products-manage': ?> <script> jQuery(document).ready(function($) { $('#product_cats_checklist').children('.product_cats_checklist_item').each(function() { if( $(this).children('.product_taxonomy_sub_checklist').length > 0 ) { $(this).children('label').children('input').hide(); } }); }); </script> <?php break; } } add_action( 'after_wcfm_load_views', 'wcfm_pm_custom_script' );
Add this code to your child themes functions.php
Thank You!- May 18, 2020 at 7:21 pm #132661HenrietteParticipant
Hi Sushobhan,
thank you for your patience.
Unfortunately this snippet breaks my site.- May 18, 2020 at 8:23 pm #132698SushobhanKeymaster
Sorry about that 🙁
Provide me some details, maybe a snapshot to understand this better. The script only runs on the Product Editing page so other pages of the site should not be affected.
Let me know.
Thank You!- May 18, 2020 at 9:13 pm #132710HenrietteParticipant
Please don’t be sorry, no need to.
Now first code breaks my site too. Before the update it was working fine.
At least for the main category restriction.
So I can not give you screendumps of vendor product page.I don’t know if it works to give you vendor access in private post so you can see it in your mailbox and than I remove the credentials in post again.
I will try okay?Meanwhile, here are printscreens of the snippets and the error message on my site in attachments.
Attachments:
You must be logged in to view attached files.- May 18, 2020 at 9:17 pm #132715HenrietteParticipantThis reply has been marked as private.
- May 18, 2020 at 10:16 pm #132747SushobhanKeymasterThis reply has been marked as private.
- May 19, 2020 at 9:38 am #132904HenrietteParticipantThis reply has been marked as private.
- May 16, 2020 at 7:46 am #131642HenrietteParticipant
Hope you don’t mind
I certainly don’t. Thank you very much.
- May 18, 2020 at 9:31 am #132407HenrietteParticipant
Request to keep this topic open.
Not solved yet but first I’m busy on fixing many emails to customer as described in another topic.
Thank you. - May 18, 2020 at 10:06 pm #132738SushobhanKeymaster
Hi,
I don’t think the problem is due to this code snippet. Remember earlier how a single bracket was causing trouble to your functions.php, I think it’s a similar issue. Have you changed anything in your functions.php recently? If possible please switch to Code Snippet plugin. That option is much easier to handle.
Thank You.
- AuthorPosts
- You must be logged in to reply to this topic.