Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM › Hide Product Creation Fields. Give pre-set (default) values (Product Manager)
Tagged: Hide fields, preset fields, product creation, product manager, wcfm, WCFM ultimate
- This topic has 12 replies, 2 voices, and was last updated 4 years, 7 months ago by pisidia.
- AuthorPosts
- March 18, 2020 at 3:15 pm #112137pisidiaParticipant
Hi! I’m using WCFM Ultimate, and have a question:
There are fields in the Product creation screen for Vendors, that I would like to customize. I have been able to make “Virtual” and “Downloadable” selected (enabled), and hidden, so that the values are set, and the Vendor cannot even see them. (I used code in functions.php that you provided in another thread.)
I would like to do the same for other fields, but have not been able to:
1. “Sold Individually” should be checked (enabled) and not accessible to Vendor when creating product
2. “Regular Price” – I would like this to be pre-set and hidden from Vendor (Right now I can only hide the field from Vendor, but cannot give it a pre-set value.)
3. “Download Limit” and “Download Expiry” – I would like these fields to also be pre-set, and hidden from Vendor.Many thanks
- March 19, 2020 at 1:32 pm #112249Sarmistha ChakrabortyMember
Hello,
add_filter( 'wcfm_product_fields_stock', 'wcfm_custom_wcfm_product_fields_stock', 150, 3 ); function wcfm_custom_wcfm_product_fields_stock( $stock_fileds, $product_id, $product_type ) { global $WCFM; if( isset( $stock_fileds['sold_individually'] ) ) { $stock_fileds['sold_individually']['dfvalue'] = 'enable'; } return $stock_fileds; } //wcfm_product_fields_downloadable add_filter( 'wcfm_product_fields_downloadable', 'wcfm_custom_wcfm_product_fields_downloadable', 150, 3 ); function wcfm_custom_wcfm_product_fields_downloadable($fields, $product_id, $product_type) { $fields['download_limit']['value'] = 10; //Set your product download limit $fields['download_expiry']['value'] = 2; //Set your product download expiry return $fields; } add_filter('wcfm_product_manage_fields_pricing','custom_price_set',100,5); function custom_price_set($fields, $product_id, $product_type, $wcfm_is_translated_product, $wcfm_wpml_edit_disable_element) { $fields['regular_price']['value'] = 100; //Set your product price return $fields; } add_filter( 'body_class', function( $classes ) { $userid = get_current_user_id(); if(wcfm_is_vendor($userid)) { $classes = array_merge( $classes, array( 'vendor-dashboard' ) ); } return $classes; });
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/And
Add this below css to your activated theme’s style.css
.vendor-dashboard .download_limit,.vendor-dashboard #download_limit,.vendor-dashboard .download_expiry,.vendor-dashboard #download_expiry,.vendor-dashboard .sold_individually,.vendor-dashboard #sold_individually,.vendor-dashboard #regular_price,.vendor-dashboard .regular_price { display: none !important; }
Thanks.
- March 20, 2020 at 2:30 am #112317pisidiaParticipant
Brilliant! Thank you so much, Sarmistha – It works perfectly!
- March 20, 2020 at 2:49 am #112319pisidiaParticipant
One more question – Is it possible to do the same as above for a specific Category? To have it pre-selected and also hidden from Vendor?
Thank you once again!
- March 20, 2020 at 11:50 am #112358Sarmistha ChakrabortyMember
You are welcome 🙂
Do you want hide “category” section for vendor Or want to hide a “specific category” from vendor?
- March 20, 2020 at 6:55 pm #112391pisidiaParticipant
Hi Sarmistha, I think I can hide “category” completely from the admin section. But I would like to make the category “selected”. For the specific category, Vendor would not be able to un-select it or even see it. Is this possible?
- March 23, 2020 at 4:54 pm #112802Sarmistha ChakrabortyMember
Hi,
Ok, Yes turn off the Category capability for vendor from admin, And add this code to your child theme’s functions.php –
add_action( 'after_wcfm_products_manage_meta_save', 'fn_custom_product_tag_save',10,2 ); function fn_custom_product_tag_save($new_product_id, $wcfm_products_manage_form_data) { $userid = get_current_user_id(); if(wcfm_is_vendor($userid)) { $cat_id = 10; //Add your Product Category ID wp_set_object_terms( $new_product_id, $cat_id, 'product_cat' ); } }
Thanks.
- March 25, 2020 at 3:33 am #113016pisidiaParticipant
It works great, Sarmistha! Thanks a million!
- March 25, 2020 at 11:37 am #113060Sarmistha ChakrabortyMember
You are always welcome 🙂
Let me know if there’s anything else we can help you with.
Can we ask for a favor? Would you mind taking a few minutes to review our plugin at https://wordpress.org/support/plugin/wc-multivendor-marketplace/reviews/ and let others know about your 5 Star experience with WCFM Marketplace. Also, follow us on Twitter https://twitter.com/wcfmmp for more exciting news, important updates, and irresistible offers. - March 27, 2020 at 5:59 pm #113482pisidiaParticipant
Review done, Sarmistha! Thank you once again
- March 27, 2020 at 7:09 pm #113525pisidiaParticipant
Hey Sarmistha. So one more issue I have run into:
When I turn off “Category” in the Vendor Capabilities, it turns off many things in the Vendor Dashboard:
1. Under “Products” in the Vendor Dashboard, the “taxonomies” column disappears
2. On the “Manage Product” page, the “Category” selection disappears, but also all Custom Taxonomy selection boxes disappear.Is it possible to keep the Vendor Capability “Category” ON for Vendor in Capabilities section, BUT remove only the “Categories” selector for Vendor in the “Manage Product” section, but keep custom taxonomies selectors available for Vendor in the “Manage Product” section?
So Vendor should be able to see any custom taxonomies and select them, but cannot see the “Categories” section at all. Is this possible?
- March 28, 2020 at 11:04 am #113641Sarmistha ChakrabortyMember
Hi,
Add this below css to your activated theme’s style.css
.vendor-dashboard .wcfm_product_manager_cats_checklist_fields,.vendor-dashboard p.wcfm_add_new_category { display: none !important; }
And keep the Vendor Capability “Category” ON for Vendor in Capabilities section.
Thanks.
- March 29, 2020 at 1:55 am #113762pisidiaParticipant
Hi Sarmistha, that worked! It was also removing custom taxonomy checklist together with category checklist, so after your code, I added:
.vendor-dashboard .wcfm_product_manager_cats_checklist_fields.wcfm_product_taxonomy_customTaxonomy { display: block !important; }
Thank you so much once again!
- AuthorPosts
- You must be logged in to reply to this topic.