Hide Product Creation Fields. Give pre-set (default) values (Product Manager)

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 Hide Product Creation Fields. Give pre-set (default) values (Product Manager)

Viewing 9 reply threads
  • Author
    Posts
    • #112137
      pisidia
      Participant

      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

    • #112249

      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.

    • #112317
      pisidia
      Participant

      Brilliant! Thank you so much, Sarmistha – It works perfectly!

    • #112319
      pisidia
      Participant

      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!

      • #112358

        You are welcome 🙂
        Do you want hide “category” section for vendor Or want to hide a “specific category” from vendor?

    • #112391
      pisidia
      Participant

      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?

      • #112802

        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.

    • #113016
      pisidia
      Participant

      It works great, Sarmistha! Thanks a million!

    • #113060

      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.

    • #113482
      pisidia
      Participant

      Review done, Sarmistha! Thank you once again

    • #113525
      pisidia
      Participant

      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?

      • #113641

        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.

    • #113762
      pisidia
      Participant

      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!

Viewing 9 reply threads
  • You must be logged in to reply to this topic.