Home Forums WC Vendors Free Support sort vendor by shop setting field

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #5474
    sanjay
    Participant

    I have added two custom field (radio buttons) in shop setting page of vendors
    field name:- 1)Wellness
    2)Dieticians
    one field is compulsory selected by each vendor.

    now i want display vendor list into two different section on same page called vendor list
    which will sort vendor by Wellness and Dieticians field’s.

    like bellow which will display front of each other
    ================== ==================
    | Wellness | |Dieticians |
    ================== ==================
    | Vendor1 | |Vendor1 |
    | Vendor2 | |Vendor2 |
    | Vendor3 | |Vendor3 |
    ================= ==================

    is this possible with using any hook or any other way.

    #5486
    WC Vendors Support
    Participant

    You’d probably want to build your own shortcode for this.

    https://github.com/wcvendors/wcvendors/blob/7d52c9db9762f448fcb840af91a3f2fc8f138a03/classes/includes/class-wcv-shortcodes.php#L546

    ^^^ That’s the wcv_vendorslist shortcode. Copying it and modifying it to sort based on the custom fields you are looking for would be a good way to solve this. You’d simply copy the shortcode php into your themes functions.php file, rename the shortcode, and change the output to show what you want and how you want it. Then, just use your new shortcode on a page.

    Another method, would be to create an actual dropdown for your sorted field, and to do this follow this guide that I found by searching Google for “Sort WooCommerce by custom fields”.

    https://www.skyverge.com/blog/sort-woocommerce-products-custom-fields/

    Hope this helps!

    #5503
    sanjay
    Participant

    i am very new to php and wordpress at this point i am not able to figure out how do i code or query’s to achive this i have seen your plugin code for vendor list but i am to much confusing how do i start with code to achieve this goal can you please provide some sample code to sort vendor by them custom field.

    #5513
    WC Vendors Support
    Participant

    Now is probably a good time to learn PHP then! 🙂 Customizations from us are a paid task. We’ll point you to the right direction, but if you need us to do it all for you, it’s $49/hr! Hit us up on the Contact Page at the top if you’d like help via this route.

    Ben

    #5789
    rstillwell
    Participant

    I would like to do something similar to this as well. I would like to have a shortcode that generates vendors from a specific geo-location that the vendors select when registering. I created my custom shortcode, have a meta field the vendor selects, and created the attribute for that meta field. The only problem now is I cannot seem to only select vendors with that meta field. If my shortcode is [wc_vendors_location location=”USA”] it shows vendors from everywhere, not just USA. I am using the shortcode from wcv_vendorslist, I simply added in the location attribute.

    Could my issue be that the wcv_vendorslist is not calling any user_meta, so therefore my custom field is not found? Or am I missing something entirely?

    Thank you for your help!

    Randall

    #5790
    WC Vendors Support
    Participant

    That’s what you would probably want to do, is copy the wcv_vendorslist shortcode and then create your own with it. If you come up with a successful way of doing this, and would like to write a quick “howto” guide, I’d love to post it in the KnowledgeBase as a new article!

    wcv_vendorslist can be found here:

    https://github.com/wcvendors/wcvendors/blob/7d52c9db9762f448fcb840af91a3f2fc8f138a03/classes/includes/class-wcv-shortcodes.php#L546

    ….and yes, you’d need to add in your attributes and a way to query for them. By following the code in the shortcode already you’ll eventually find an easy way.

    Cheers

    Ben

    #5791
    rstillwell
    Participant

    Figured it out, I will be posting a little tutorial come Monday.

    Thanks!

    Randall

    #5792
    WC Vendors Support
    Participant

    Awesome! Thanks 🙂

    #5953
    Glenn Carlson
    Participant

    Hi Randall,
    Were you able to get a little tutorial put together? I am not a software guy by trade so something that shows how to do this would be great. I need to have vendor location put in somewhere.

    #5955
    rstillwell
    Participant

    Hey guys! Sorry! I recently got slammed with some work.

    Overall, here is the concept. I needed a shortcode that would allow me to separate vendors by location. To do this, I required users to select a location during their registration and in their store settings. Then I pulled that meta info into a shortcode which filtered and displayed only those vendors.

    Here is an example: [wc_vendors_location location=”Alabama”]

    So here is how I set everything up. I use WP User Frontend Pro. Found here. This is important because that is how I attached the location meta to the vendor. So, here we go.

    First I went into the registration form designated for my vendors settings page. (Please refer to this post here for that form) I added a dropdown with all the locations I needed my vendors to select. This is/was the easiest part.

    Next I created this code:
    http://pastebin.com/xusSRBv1
    I placed that in my child theme’s functions.php.

    To give you a quick breakdown of how that worked, I simply copied the shortcode for showing ALL vendors (See posts above). I then took out the pieces that related to pagination (I didn’t need it, you might).
    Then under the – “extract ( shortcode_atts……”
    I added – ‘location’ => ”,
    This is responsible for the part of the shortcode that can be adjusted.
    [wc_vendors_location location=”filtered piece”]

    Then I added in the arguments needed for when this shortcode searches for vendors. Under “$vendor_total_args = array…..”

    I added:
    ‘meta_key’ => ‘location’,
    ‘meta_value’ => $location,

    meta_key is telling it to look at the meta information “location” but not what that actual word is. That is handled by meta_value. That is why both are needed.

    Once those are both inserted, I simply deleted the pagination as I don’t have that many vendors, but you might want to leave it in if you need it. If that is the case, don’t forget to add your meta keys and values there.

    Ultimately, this ended up working for me. I by no means say I am an expert in php. I have enough knowledge to get me into trouble. So please, if something doesn’t work for you, lets figure it out!

    Also, if you don’t have WP User Frontend, you can refer to this post to create your own area to fill out. (https://www.wcvendors.com/help/topic/manipulating-the-vendors-shop-settings/)

    I really hope this helps someone and that you all have a great day!

    Thanks!

    Randall

    #5963
    Jamie
    Keymaster

    Hi Randall

    Thanks for the write up! I’m sure when Ben awakes he’ll take a look and maybe put it into a KB article.

    cheers,

    Jamie.

    #5986
    rstillwell
    Participant

    Of course! I am glad I can help. Thanks for making a great plugin!

    #5994
    WC Vendors Support
    Participant
    #23085
    Claude Martins
    Participant

    Greetings to all. Thank you for your time, effort and kindness.
    I’ve been trying for over a week to apply the above to my site but to no avail, so I’ve decided to seek assitance from the Collective-Forum.

    Using WordPress Plugin ACF for Custom Fields I have managed to place the Custom Field in Each Vendor’s Profile Settings, where they can choose their City/State.

    What I need to accomplish is>
    1. Configure a search filter so Customers can filter Products by Vendor’s Location.
    2. Show each Vendor’s City/State on the FrontEnd Next Sold by Vendor.

    Thank you.

    #39096
    ravi
    Participant

    Randall,

    I tried the way you explained but somehow it is not working.

    I was wondering if it works in the free version?

    I created the meta_key location using wp frontend pro and could manage to get the fields showing up in a custom form generated by the plugin and also in the user profile.

    i copied the code you have submitted as it is and i am not able to get the desired result.

    Can you please help me put it in the workable way.

    Currently working on my local environment and would put it for your access on a web server by tonight.

    Pls. help.

Viewing 15 posts - 1 through 15 (of 15 total)
  • The forum ‘WC Vendors Free Support’ is closed to new topics and replies.