Custom Settings Fields

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!

Viewing 4 reply threads
  • Author
    Posts
    • #106672
      ashley.younguk
      Participant

      Hello,

      I would like to add a custom field under the store settings just under the store email field called ‘Store Type’, its just a simple plain text field (not text area). I would then like to display this using the shortcode [wcfm_store_info id=”” data=”store_type”].

      Can you help please?

    • #106837

      Hello,

      add_filter('wcfm_marketplace_settings_fields_general','wcfm_marketplace_add_custom_field_settings_fields_general',10,2);
      function wcfm_marketplace_add_custom_field_settings_fields_general($fields, $user_id) {
      	$vendor_data = get_user_meta( $user_id, 'wcfmmp_profile_settings', true );
      	$store_type          = isset( $vendor_data['v_store_type'] ) ? esc_attr( $vendor_data['v_store_type'] ) : '';
      	if(isset($fields['store_name'])) {
      	$fields = array_slice($fields, 0, 3, true) +
      	array("v_store_type" => array('label' => __('Store Type', 'wc-frontend-manager') , 'type' => 'text', 'class' => 'wcfm-text wcfm_ele wcfm_name_input', 'label_class' => 'wcfm_title wcfm_ele', 'value' => $store_type )) +
      																	array_slice($fields, 3, count($fields) - 3, true) ;
      	}
      	return $fields;
      }
      add_action( 'wcfm_wcfmmp_settings_update','fn_wcfm_vendor_settings_storetype_update', 30, 2);
      add_action( 'wcfm_vendor_settings_update','fn_wcfm_vendor_settings_storetype_update', 30, 2);
      function fn_wcfm_vendor_settings_storetype_update($user_id, $wcfm_settings_form ){	
      	$wcfm_settings_form_data_new = array();
      	parse_str($_POST['wcfm_settings_form'], $wcfm_settings_form_data_new);	
      	$wcfm_settings_form_data_storetype = array();
      	if(isset($wcfm_settings_form_data_new['v_store_type']) && !empty($wcfm_settings_form_data_new['v_store_type'])) {
      		$wcfm_settings_form_data_storetype['v_store_type'] = $wcfm_settings_form_data_new['v_store_type'];
      	}
      	$wcfm_settings_form = array_merge( $wcfm_settings_form, $wcfm_settings_form_data_storetype );
      	update_user_meta( $user_id, 'wcfmmp_profile_settings', $wcfm_settings_form );
      }
      
      add_filter('wcfmmp_additional_store_info','vendor_store_type_wcfmmp_additional_store_info',10,3);
      function vendor_store_type_wcfmmp_additional_store_info($data_value, $data_info, $store_id) {
      	$vendor_data = get_user_meta( $store_id, 'wcfmmp_profile_settings', true );
      	$store_type          = isset( $vendor_data['v_store_type'] ) ? esc_attr( $vendor_data['v_store_type'] ) : '';
      	if($data_info == 'store_type') {
      		$data_value = '<p>'.$store_type.'</p>';
      	}	
      	return $data_value;
      }

      Thanks.

    • #106869
      ashley.younguk
      Participant

      @Sarmistha Chakraborty

      Thank you – this has added the field – now how can I display it with the shortcode [wcfm_store_info id=”” data=”store_type”]?

      Also how can I make this field mandatory and how can I add a tooltip help icon?

      Thanks

    • #106870
      ashley.younguk
      Participant

      Sorry – the shortcode [wcfm_store_info id=”” data=”store_type”] works fine 🙂 thank you!

      I now just need to know how to make it a required field and also to add a help tooltip 🙂

    • #106872
      ashley.younguk
      Participant

      Don’t worry I figure it out…

      I needed to add

      'hints' => __( 'Product tags are descriptive labels you can add to your products. Popular search engines can use tags to get information about your store. You can add more than one tag separating them with a comma.', 'wc-frontend-manager' )

      In the array for the help tooltip and

      'required' => 1

      Thanks for your help – you guys rock!! 🙂

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