Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Ultimate › Vendor can select only the lowest sublevel category for new product.
Tagged: add new product, Categories
- This topic has 3 replies, 2 voices, and was last updated 4 years, 8 months ago by WCFM Forum.
- AuthorPosts
- February 14, 2020 at 6:32 pm #107167marcinzywyParticipant
Hi WC Lovers,
I would like vendors to be able to choose only the lowest subcateogry when adding new product.
For example, I have categories such as:
* Main category
– Subcategory 1
– Subcategory 2
–> Subcategory 2A
–> Subcategory 2B
– Subcategory 3Therefore, vendor should not be able to choose Main Category, or Subcategory 2, because these categories have their subcategories. So the system should not allow to publish/add this product, as the lowest subcategory is not selected. Also, when vendor selects Subcategory 2A, the product should be added only to Subcategory 2A (not to Main Category, Subcategory 2).
Please let me know if this is possible to achieve or not.
- February 19, 2020 at 2:34 pm #107802WCFM ForumMember
HI,
Please add this code to your site for the purpose –
add_action( 'after_wcfm_products_manage', function() { ?> <script> jQuery(document).ready(function($) { setTimeout(function() { $('#product_cats_checklist').children('.product_cats_checklist_item').each(function() { if( $(this).children('.product_taxonomy_sub_checklist').length > 0 ) { $(this).children('.checklist_type_product_cat').addClass('wcfm_custom_hide'); } }); }, 1000); }); </script> <?php }, 50 );
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/Thank You
- February 19, 2020 at 3:07 pm #107822marcinzywyParticipant
Thank you for the code, however this code doesn’t work.
My vendor can still publish product using main category, any sub level category.
Is there anything I should change in this code to be ‘applicable’ for my website?
Thank you for your help.
- February 25, 2020 at 12:04 pm #108648WCFM ForumMember
Please contact us here – https://wclovers.com/woocommerce-multivendor-customization/
- AuthorPosts
- You must be logged in to reply to this topic.