Home Forums WC Vendors Free Support Get shopname, shoplink and shop description in custom loop?

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 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #13658
    wzshop
    Participant

    Hi,
    I have a custom loop that goes through all the users that have the role Vendor. So basically through all the shops.
    I would like to get foreach $shops as $shop the shopname, shoplink (permalink to shop) and shop description (preferably) without any html markup (filter out images etc.)

    My loop is basically as simple as:

    $query_args = array(
    'role'         => 'Vendor',
    'order'        => 'ASC'
    );
    
    $shops = get_users( $query_args );
    // Array of stdClass objects.
    foreach ( $shops as $shop ) {
    
    }

    What php code can i use to get these values?
    Thanks.

    #13666
    WC Vendors Support
    Participant

    Everything is stored as user meta.

    get_user_meta( $user_id, 'pv_paypal', true ); // PayPal Email
    get_user_meta( $user_id, 'pv_shop_name', true ); // Shop Name
    get_user_meta( $user_id, 'pv_seller_info', true ); // Seller Info
    get_user_meta( $user_id, 'pv_shop_description', true ); // Shop Description
    #13712
    wzshop
    Participant

    Hi Thank you,
    How can i get the permalink of the shop?
    Thanks again

    #13714
    WC Vendors Support
    Participant

    Hi wzshop:

    /vendors/user_login

    So if your username is “ben” it would be /vendors/ben

    Easy as that. 🙂

    #13715
    wzshop
    Participant

    I understand but what about spaces and stuff?

    #13717
    WC Vendors Support
    Participant

    I don’t know. Should work just fine. Test it, let us know.

    #13718
    wzshop
    Participant

    No it is not. i have a shopname that has the variable shoplink: domain.com/vendor/test-2 for instance. This wont work for domain.com/vendor/test 2
    In your templates you use $shoplink variable but how can i populate this variable outside of your plugin in a custom loop?

    #13720
    WC Vendors Support
    Participant

    That sucks. Guess we’ll do it the hard way, then. 🙂

    $vendor_shop_link = site_url( WC_Vendors::$pv_options->get_option( 'vendor_shop_permalink' ) .'/' .$user_id->pv_shop_slug );

    #13731
    wzshop
    Participant

    Thanks!
    This however is not showing the shopname slug:

    foreach ( $shops as $shop ) {
    $user_id = $shop->ID;
    $vendor_shop_link = site_url( WC_Vendors::$pv_options->get_option( 'vendor_shop_permalink' ) .'/' .$user_id->pv_shop_slug );
    }
    

    The above is only showing: domain.com/vendor_slug//

    Am i missing something?

    #13771
    WC Vendors Support
    Participant

    This is where you use print_r or echo to display the values you are getting, so you know what’s broken where. 🙂

    e.g.,
    
    $user_id = $shop->ID;
    echo 'User ID is ' . $user_id;
    rinse and repeat....
    

    https://github.com/wcvendors/wcvendors/search?utf8=%E2%9C%93&q=pv_shop_slug is how we look up the pv_shop_slug, it’s just a meta field. You might just rewrite it so that:

    $vendor_shop_slug = get_user_meta( $user_id, 'pv_shop_slug', true);
    $vendor_shop_link = 'http://www.yourwebsite.com/vendors/'.$vendor_shop_slug.'/';
    #13848
    wzshop
    Participant

    Awesome,

    $vendor_shop_slug = get_user_meta( $user_id, 'pv_shop_slug', true);
    $vendor_shop_link = 'http://www.yourwebsite.com/vendors/'.$vendor_shop_slug.'/';

    Did the trick. thanks a million!

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