Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Vendors › Vendors Categories
- This topic has 9 replies, 2 voices, and was last updated 5 years, 10 months ago by WCFM Forum.
- AuthorPosts
- January 29, 2019 at 11:24 am #45684info79Guest
Hello,
We have some questions regarding vendors.1.Is it possible when a new Vendor registers to have the option to select which category best suits them for their store ?
We’ve added a custom field so that the vendors can choose their category but it’s not quite what we are looking for, as we can’t use this field as a search filter.
For example we want to have vendor categories such as electronics, clothes, accessories etc (if our vendors sell products) or specialties (like dentists, pathologists, photographers etc) if they offer services. From that categories we want them to make their choice during the membership steps, so we can later query our vendors by their category.
We’ve tried with the Vendors Group but it is not what we want, because we can only assign one group to our subscription plans, but we need more than one group per plan.2.If vendor categories are possible we want to make a search based on that categories, using the Geo my WP plugin. Is this also possible?
Any help would be appreciated.
Thank you in advance. - January 29, 2019 at 5:12 pm #45720WCFM ForumMember
HI,
1. Please try this code –
add_action( 'end_wcfm_membership_registration_form', function() { $selected_categories = array(); $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0&parent=0' ); $p_category_options = array(); foreach ( $product_categories as $cat ) { $p_category_options[$cat->term_id] = array( 'name' => $cat->name, 'parent' => 0 ); } if( !empty( $p_category_options ) ) showRegistrationCategoryHierarchySelector( $p_category_options, $selected_categories ); ?> <script> jQuery(document).ready(function($) { $('.wcfm_category_hierarchy').each(function() { $(this).change(function() { $level = parseInt($(this).data('level')); $value = $(this).val(); if( $('.p_category_'+($level+1)).length > 0 ) { $('.p_category_'+($level+1)).addClass('wcfm_custom_hide'); $('.p_category_label_'+($level+1)).addClass('wcfm_custom_hide'); if( $value ) { $.each($value, function( $i, $svalue ) { if( $('.p_category_'+($level+1)).find('.cat_parent_'+$svalue).length > 0 ) { $('.p_category_'+($level+1)).removeClass('wcfm_custom_hide'); $('.p_category_label_'+($level+1)).removeClass('wcfm_custom_hide'); } }); } $level_1 = $('.p_category_'+($level+1)).val(); $('.p_category_'+($level+1)).val(''); $('.p_category_'+($level+1)).find('option').addClass('wcfm_custom_hide'); if( $value ) { $.each($value, function( $i, $svalue ) { $('.p_category_'+($level+1)).find('.cat_parent_'+$svalue).removeClass('wcfm_custom_hide'); }); } if( $level_1 ) { if( !$('.p_category_'+($level+1)).find('option[value="'+$level_1+'"]').hasClass('wcfm_custom_hide') ) { $('.p_category_'+($level+1)).val($level_1); } } $('.p_category_'+($level+1)).change(); } }).change(); }); }); </script> <?php }); function showRegistrationCategoryHierarchySelector( $p_category_options, $selected_categories, $level = 0 ) { global $WCFM, $WCFMch; $p_category_child_options = array(); $ptax_custom_arrtibutes = apply_filters( 'wcfm_taxonomy_custom_attributes', array(), 'product_cat' ); ?> <p class="wcfm_title p_category_label_<?php echo $level; ?>"> <strong> <?php echo apply_filters( 'wcfm_taxonomy_custom_label', '', 'product_cat' ); if( $level ) _e( 'Sub-', 'wcfm-category-hierarchy' ); _e( 'Categories', 'wc-frontend-manager' ); ?> </strong> </p> <label class="screen-reader-text" for="product_cats"> <?php if( $level ) echo __( 'Sub-', 'wcfm-category-hierarchy' ); echo apply_filters( 'wcfm_taxonomy_custom_label', __( 'Categories', 'wc-frontend-manager' ), 'product_cat' ); ?> </label> <select id="p_category_<?php echo $level; ?>" style="height: auto;" multiple name="reg_category[<?php echo $level; ?>][]" class="wcfm-select wcfm_category_hierarchy p_category_<?php echo $level; ?>" data-level="<?php echo $level; ?>" data-catlimit="1" <?php echo implode( ' ', $ptax_custom_arrtibutes ); ?>> <option value=""><?php _e( '-- Select Category --', 'wcfm-category-hierarchy' ); ?></option> <?php foreach( $p_category_options as $term_id => $term_details ) { $cat_group_class = 'cat_parent_' . $term_details['parent']; echo '<option class="' . $cat_group_class . '" value="' . esc_attr( $term_id ) . '"' . selected( in_array( $term_id, $selected_categories ), true, false ) . '>' . __( esc_html( $term_details['name'] ), 'wcfm-category-hierarchy' ) . '</option>'; $product_child_taxonomies = get_terms( 'product_cat', 'orderby=name&hide_empty=0&parent=' . absint( $term_id ) ); if ( $product_child_taxonomies ) { foreach ( $product_child_taxonomies as $cat ) { $p_category_child_options[$cat->term_id] = array( 'name' => $cat->name, 'parent' => $term_id ); } } } ?> </select> <?php $level++; if( !empty( $p_category_child_options ) ) showRegistrationCategoryHierarchySelector( $p_category_child_options, $selected_categories, $level ); } add_action( 'wcfm_membership_registration', function( $member_id, $wcfm_membership_registration_form_data ) { if( isset( $wcfm_membership_registration_form_data['reg_category'] ) ) { update_user_meta( $member_id, 'wcfm_vendor_reg_category', $wcfm_membership_registration_form_data['reg_category'] ); } }, 50, 2 );
Well, this will save user’s selected categories in “wcfm_vendor_reg_category” this user meta.
2. Sure, you require GEO my WP Premium extension for this
Thank You
- February 5, 2019 at 9:06 pm #46786WebstersGuest
Hello,
thank you for your help!
The code worked fine and now the vendor “categories” are stored in the database in the user meta.
How can we customize the search based on that info?
Thank you again in advance. - February 6, 2019 at 5:25 am #46806WCFM ForumMember
HI,
How can we customize the search based on that info?
– You have to implement this custom.
Well, Store List page already has Category filter option.
Thank You
- February 6, 2019 at 11:49 am #46867WebstersGuest
The Category Filter you are referring to is for Product Categories, what we are actually trying to achieve is to give our visitors the ability to search for vendors based not only by the filters you already provide but also based on their business type (the user meta you’ve already helped us build).
Our issue here is that the Store List page is outputted by the use of a shortcode and not by a WCFM Store file that we can overwrite by including it in our theme, the way we are doing it with any other wcfm template file.
We ‘ve already asked if this type of search can be achieved with the use of GEO my WP plugin, but search based on user meta is not supported and needs custom coding in order to achieve it.
We prefer not to use extra plugins unless it’s absolutely necessary, so if it’s possible with WCFM and if you can point us to the right direction on how to add that user meta on the search filters, it would be great and it will save us a great amount of time and effort.
- February 7, 2019 at 11:45 am #47013WCFM ForumMember
Hi,
Well, first of all every thing is possible.
But, which user meta you are talking about ? As I remember, I helped you to create “Product Categories” field in registration form.
DO you want to search by those selected categories!
Thank You
- February 12, 2019 at 1:24 pm #47905WebstersGuest
Hello,
we are talking about the user meta that are stored in the database with meta key (bussiness-type) and meta value is the selected option that the vendor chooses when registers that we have already create by using Registration Form Custom Fields in the backend.
So we want to offer the ability to the user to make a search based on that info.
For example if the visitor is looking for a Vendor that offers services and not products we want the search engine to able to find this information.
Is this possible ?
Thank you in advance. - February 12, 2019 at 4:52 pm #47937WCFM ForumMember
HI,
It’s possible, I will know you can setup this.
Thank You
- February 22, 2019 at 7:24 am #49478islam salahGuest
hello
that feature i was about to ask you for it would be GREAT if you add this Feature to Next Update ++ Making a vendor category filed in the registration form and making it searchable with sidebar in store listing Page
thank you WC Lovers support Team
i Really LOVE you
- February 22, 2019 at 8:22 am #49501WCFM ForumMember
HI,
You are welcome 🙂
“making it searchable with sidebar in store listing Page”
– WCFM Marketplace already has this feature. You have to add this widget to the store list page sidebar – https://ibb.co/dPyV097Thank You
- AuthorPosts
- The topic ‘Vendors Categories’ is closed to new replies.