Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Vendor store page tabs-Need Code adjustment
- This topic has 8 replies, 2 voices, and was last updated 4 years, 5 months ago by hani.
- AuthorPosts
- June 3, 2020 at 5:16 pm #138024haniParticipant
Hi,
Would you please provide me adjusted code to feed the template of a new tab in vendor store page from new registration fields.I created new field in the vendor registration form.
add_action( ‘wcfmmp_rewrite_rules_loaded’, function( $wcfm_store_url ) {
add_rewrite_rule( $wcfm_store_url.’/([^/]+)/art_works?$’, ‘index.php?’.$wcfm_store_url.’=$matches[1]&art_works=true’, ‘top’ );
add_rewrite_rule( $wcfm_store_url.’/([^/]+)/art_works/page/?([0-9]{1,})/?$’, ‘index.php?’.$wcfm_store_url.’=$matches[1]&paged=$matches[2]&art_works=true’, ‘top’ );
}, 50 );add_filter( ‘query_vars’, function( $vars ) {
$vars[] = ‘art_works’;
return $vars;
}, 50 );add_filter( ‘wcfmmp_store_tabs’, function( $store_tabs, $store_id ) {
$store_tabs[‘art_works’] = ‘Art Works’;
return $store_tabs;
}, 50, 2 );add_filter( ‘wcfmp_store_tabs_url’, function( $store_tab_url, $tab ) {
if( $tab == ‘art_works’ ) {
$store_tab_url .= ‘art_works’;
}
return $store_tab_url;
}, 50, 2 );add_filter( ‘wcfmp_store_default_query_vars’, function( $query_var ) {
global $WCFM, $WCFMmp;if ( get_query_var( ‘art_works’ ) ) {
$query_var = ‘art_works’;
}
return $query_var;
}, 50 );add_filter( ‘wcfmmp_store_default_template’, function( $template, $tab ) {
if( $tab == ‘art_works’ ) {
$template = ‘store/wcfmmp-view-store-art-works.php’;
}
return $template;
}, 50, 2); - June 3, 2020 at 8:46 pm #138100haniParticipant
Can someone answer? i feel answers are only for specific topics
- June 4, 2020 at 12:56 pm #138262Sarmistha ChakrabortyMember
Hello,
You have already the demo code on how to add “new tab” in vendor’s store page.
Replace the “art_works” as per your require slug, and in “wcfmmp-view-store-art-works.php” file write below code to get “custom fields value”-$wcfmvm_custom_infos = (array) get_user_meta( $vendor_id, 'wcfmvm_custom_infos', true ); //get all custom field data if( !empty( $wcfmmp_addition_info_fields ) ) { foreach( $wcfmmp_addition_info_fields as $wcfmvm_registration_custom_field ) { if( !isset( $wcfmvm_registration_custom_field['enable'] ) ) continue; if( !$wcfmvm_registration_custom_field['label'] ) continue; $field_class = ''; $field_value = ''; $wcfmvm_registration_custom_field['name'] = sanitize_title( $wcfmvm_registration_custom_field['label'] ); $field_name = 'wcfmmp_additional_infos[' . $wcfmvm_registration_custom_field['name'] . ']'; $field_id = md5( $field_name ); $ufield_id = ''; if( !empty( $wcfmvm_custom_infos ) ) { $field_value = isset( $wcfmvm_custom_infos[$wcfmvm_registration_custom_field['name']] ) ? $wcfmvm_custom_infos[$wcfmvm_registration_custom_field['name']] : ''; echo $wcfmvm_registration_custom_field['label'].' '.$field_value; } } } }
Thanks.
- June 4, 2020 at 4:17 pm #138326haniParticipantThis reply has been marked as private.
- June 5, 2020 at 8:57 pm #138861Sarmistha ChakrabortyMemberThis reply has been marked as private.
- June 5, 2020 at 9:43 pm #138876haniParticipantThis reply has been marked as private.
- June 5, 2020 at 9:44 pm #138878
- June 5, 2020 at 10:30 pm #138902Sarmistha ChakrabortyMember
Hello,
Add the condition –
if($wcfmvm_registration_custom_field_key == 'approvals') {}
Thanks.
- June 5, 2020 at 10:56 pm #138912haniParticipantThis reply has been marked as private.
- AuthorPosts
- You must be logged in to reply to this topic.