Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM › Custom Settings Fields
- This topic has 4 replies, 2 voices, and was last updated 4 years, 9 months ago by ashley.younguk.
- AuthorPosts
- February 11, 2020 at 2:09 pm #106672ashley.youngukParticipant
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?
- February 12, 2020 at 5:31 pm #106837Sarmistha ChakrabortyMember
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.
- February 12, 2020 at 11:40 pm #106869ashley.youngukParticipant
@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
- February 12, 2020 at 11:54 pm #106870ashley.youngukParticipant
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 🙂
- February 13, 2020 at 12:04 am #106872ashley.youngukParticipant
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!! 🙂
- AuthorPosts
- You must be logged in to reply to this topic.