Home Forums WC Vendors Free Support Echo users shop products on another template?

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 40 posts - 1 through 40 (of 40 total)
  • Author
    Posts
  • #2423
    Jerry
    Participant

    Hi Ben!

    I wonder if there is a shortcake to echo the vendors/users/ products on another template? Im trying to add the users product to a custom profile page. Something like.. <?php echo do_shortcode(‘wcv_products vendor=”VENDOR-LOGIN-NAME”‘);?> but specific for the users products?

    #2424
    WC Vendors Support
    Participant

    Of course, there’s a Shortcodes article in the Knowledgebase. πŸ™‚

    https://www.wcvendors.com/knowledgebase/shortcodes/

    #2425
    Jerry
    Participant

    Well Yeah thats where I Found the shortcake in the example. They doesn’t seems to do the trick though. If I go to a vendors/user I see the products specific to that user. This shortcode I need to specify a specific user?

    #2426
    WC Vendors Support
    Participant

    Hi Jerry,

    Help me understand better. You want a page that shows a specific vendors products. So, you’d create that page.

    If you want the page to automatically detect the vendors products to show, you would have to code in PHP a way for it to know what vendors username to pull up. So, in this page, how would you know which vendor you want to display products for?

    In PHP if the vendors username was set as $vendor_username (which it is not, this is just an example) you would then pass $vendor_username in the do_shortcode and it would automatically pull up their listings.

    You just have to find out HOW you want to figure out whose products you wish to display. So, how will you do that? πŸ™‚ How will your page know what vendors products you wish to display?

    #2427
    Jerry
    Participant

    Hi and thanks for a answer that makes me thing forward! Im using this on a userpro profile page with an url of /profile/ser, so it should be a conditional somewhere for username. If i find that, how would i pass that together with your shortcode?

    #2428
    Jerry
    Participant

    This is what I have so far, placed at my profile template. It gives me the vendor dashboard inside the profile page, and a global product list for public profile page, like this:

    http://streetmarket.streetstylizm.com/profile/shutterfashion/

    Just need to make it a user productlist instead πŸ™‚

    <div class="inner-page-wrap woocommerce-shop-page has-no-sidebar clearfix">
    <?php } ?>
    <?php $user_id = get_current_user_id();
    if($user_id == 0){ ?>
    <div class="span12">

    <?php echo do_shortcode('[products order=asc]');?>
    </div>

    <?php }else{
    echo do_shortcode('[wcv_vendor_dashboard]');
    }?>
    </div>

    #2429
    Jerry
    Participant

    User/profile was how the profile url two post above was supposed to be. As far as i can see the plugin uses $user_id, $userpro and $user. And not sure what happend to the code up there, but you get the point i guess πŸ™‚

    #2430
    WC Vendors Support
    Participant

    Here’s the next step! πŸ™‚

    If the user of that profile page has a role of vendor, then display the shortcode. πŸ™‚ Let’s see if you can conjure it up!

    I’m unfamiliar with “Userpro” plugin, but have the code ready if you are using BuddyPress. BuddyPress has built in functions to check for the username of the current profile being viewed, so I just use that function to check if their role is “vendor” and if it is, display products via do_shortcode, else nothing. πŸ™‚

    #2431
    Jerry
    Participant

    Hi again!

    The users all have the roll of vendor, yes. I do use the shortcode I displayed above, on vendpr user roles, but still get the global list of products instead of the vendor user one. Om not sure what I should pass to the shortcode, and how really. I tried to pass a few different options in it, like userpro, user_id and vendor_id, but no luck so far!

    #2438
    WC Vendors Support
    Participant

    Let’s say that the variable name for the vendor username is $username

    #2447
    Jerry
    Participant

    Ok thanks! No variable so far seems to work.. Still pulls the global products. Dammit. Im getting way out of normal support here though, now I have something to work on.

    #2448
    WC Vendors Support
    Participant

    If it’s pulling global products, it means that the vendor=”vendors-user-name” is not getting a value, which means the variable doesn’t work.

    Here’s a trick: use print_r!

    If you think the variable is $variable, then in the PHP type:

    echo “This is the output for variable”;
    print_r ($variable);
    echo “End output for variable”;

    Then, you will see the variables output on the page. If you see nothing, the variable is non-existent or empty.

    All you need is the username as a variable to pull, and you have a solution. πŸ™‚ The guys who write that UsersPro plugin (or whatever it is) can probably tell you how to pull up the username of the profile you are viewing. It’s just tough to say what it is because I dont use that plugin at all and never heard of it before today….

    #2449
    Jerry
    Participant

    Got it! This is what I did: <?php echo do_shortcode(‘ [wcv_products vendor=”‘ .$userpro->id_to_member($user_id).'”]’ ); ?>

    #2450
    WC Vendors Support
    Participant

    Perfect! See? A nice built in function. πŸ™‚ Great job.

    #2698
    Jamie
    Participant

    Hello!

    I’m trying to do something similar without success..How can we call the listings of the author? or the original poster of the listing?

    Thanks!
    Jamie

    #2699
    WC Vendors Support
    Participant

    Hi Jamie,

    Why not use the shortcodes? You can do_echo a shortcode in any template you wish……..

    Ben

    #2702
    Jamie
    Participant

    Hi Ben,

    Thanks for the quick reply! I have been trying and I have populated listings. Now I need to limit those listings to the owner of the directory listing, i’m assuming i want to limit to the author or owner of the listing. This is what i have so far, im just not sure how to finish it.

    “echo do_shortcode(‘[wcv_products vendor=”org_author” per_page=1]’); ”

    Thanks again!

    #2703
    WC Vendors Support
    Participant

    $author_id=$post->post_author;

    That will get the author’s userID. That’s step #1. Next:

    $author_username = get_user_by( ‘id’, $author_id );

    That’ll fetch the authors info from their user profile. To display the author’s username, you would call $author_username->user_login — and that’s what we’ll use in the Shortcode.

    echo do_shortcode( ‘[wcv_products vendor=”‘. $author_username->user_login .'”]’ );

    Add those three lines and you’re good to go. I created a gist for you in case copying it is weird as sometimes the quotes can be via forum posts:

    https://gist.github.com/bentasm1/b6f66ad528b5dc2bc207

    Now the caveat is, I dont know where you’re using this shortcode. You said “Author” so that tells me you want the author of the page you are on. If the author of that page is YOU — the admin — then this wont be too useful. πŸ™‚

    #2704
    Jamie
    Participant

    I must be missing something. It is still pulling all of the listings. Each listing owned by a different user or vendor.

    #2705
    Jamie
    Participant

    I’m using this within a geodirectory listing. Should I be looking to call the owner of the directory listing.instead of the author?

    #2706
    WC Vendors Support
    Participant

    Will repost in a sec, code got garbled while styling it.

    #2709
    WC Vendors Support
    Participant

    https://gist.github.com/bentasm1/9350f0699429e7bc5e62

    With the geo listing thing, I dont know what that plugin is, or how it does whatever it does, or even what it does.

    You need to find a way to pull the authors username and inject that into the shortcode. πŸ™‚ However you pull it, is up to you and the geo plugin! I doubt that the page author is anything other than you, so I doubt the code would work to begin with.

    #2710
    Jamie
    Participant

    Same result but now I see the debug in the lislisting.

    #2711
    WC Vendors Support
    Participant

    Ok, so what you’ll have to do is ask the author of the *other* plugin how to get the variable for the authors username. I could debug it, but it’s waaaaaaay beyond the scope of free support, as it’d take me an hour to download this other plugin, install it, configure it, figure out how it works, figure out how to get the right data, test, and resend to you. As a $49 support request, I’d be happy to. But the other plugin author will probably be able to just tell you real quick and then you can plug in that variable into the shortcode and you’ll be golden. πŸ™‚

    #2712
    Jamie
    Participant

    He says:

    If the vendor is the user ID and the user has claimed the listing or he submitted it directly, than the_author_meta(‘ID’) should be what you are looking for. If it’s not the ID the_author_meta args are:

    user_login
    user_pass
    user_nicename
    user_email
    user_url
    user_registered
    user_activation_key
    user_status
    display_name
    nickname
    first_name
    last_name
    description
    jabber
    aim
    yim
    user_level
    user_firstname
    user_lastname
    user_description
    rich_editing
    comment_shortcuts
    admin_color
    plugins_per_page
    plugins_last_view
    ID

    #2713
    WC Vendors Support
    Participant
    #2714
    WC Vendors Support
    Participant

    PS — That’s one line of code, to replace them all. You wont need anything else in there.

    #2715
    Jamie
    Participant

    OK,

    I see that you are also correct in saying that that I am the author of everything
    right now so I’m adding a few more author/user accounts.

    Thanks again for your work on this plugin and yoyour awesome support!

    #2716
    WC Vendors Support
    Participant

    You bet. Have fun. πŸ™‚

    #2717
    Jamie
    Participant

    Still nothing. I cleared cache after setting the author. Im not sure what we could be missing??

    #2718
    WC Vendors Support
    Participant

    To keep going, supporting someone *elses* plugin for you, it’s $49 πŸ˜‰

    #2719
    Jamie
    Participant

    It is actually placing the author name in the content area but not limiting the listings.

    #2720
    Jamie
    Participant

    Shouldnt we really just be calling the origional author or user of the listing? This really has nothing to do with the directory other than the fact that the same user will have created both the directory listing and the product listing.

    #2728
    WC Vendors Support
    Participant

    I dont know. You said you wanted the info on how to do it for another template. This is not another template. It’s another plugin.

    Back to the $49 to support other plugins part…. πŸ™‚ This is way beyond the scope of normal customization support.

    #2729
    Jamie
    Participant

    Ok, would you be able to get it done today?

    #2730
    WC Vendors Support
    Participant

    Please post a link to the plugin you’re trying to use, I need to see how complex it is before quoting you that it would be resolved within the $49’s 1 hour of work time.

    #2737
    Jamie
    Participant

    Wpgeodirectory.com

    Ps..I’m still being blocked from your website from failed login attempts.

    #2741
    WC Vendors Support
    Participant

    Eeek. That’s a messy plugin. I will not be able to assist you with this. It’d take me half a day to figure it out. You’ll need to get support from that plugins author. I’m sorry.

    #2742
    Jamie
    Participant

    Thanks for trying….I just want to make sure I’m not guiding you in the wrong direction because in this case it really has nothing to do with the other plugin. All I am trying to do is pull the owner’s products. Your last code worked if I replaced “user_login” with “Sam”. The actual name of the user. Does that mean we are just using the wrong variable?

    #2744
    WC Vendors Support
    Participant

    Well, kinda. It’s probably not the wrong variable. Pages and posts have an “Author”. The “Author” for products, which are just custom posts called products, is the Vendor. So if you have:

    Admin – Shop owner
    Ben – Vendor #1
    Jamie – Vendor #2

    ….and the admin lists a few products, the Admin username authors that product custom post. If Ben lists a few products, Ben authors the custom post. Same for Jamie.

    The problem with the plugin, is the plugin will determine, by methods of its own, what data to pull. That data is not “owned” by anyone. And as such, the variable lessons we taught here will not function with it.

    The plugin author needs to do this, and only this, to get it to “work” for you: Provide YOU with a variable to determine which users information it is pulling. Or, provide a function, a method, something to tell us what data to put into that shortcode. Without it, the plugin is just another random plugin setup for a single user environment and quite useless to us.

    I hope you have asked that plugins author for help as you have here — because it’s easy for them to tell you what to do. Me, I’m flying blind with another persons plugin I didnt write, and no idea how their code is structured, and it’s a pretty complex plugin. It’s like asking a ten year old to perform a root canal. Sure, they could do it, but you might not like the cost of the results! πŸ™‚ πŸ™‚ That’s why I’ve suggested many times to contact that plugin developer to get you a way to fill the variable. Without it, you’re flying blind and lost……. Most (good) plugin authors would have a way to pull this for you to expand/customize their plugin. Some don’t, and those are the plugins you avoid like the plague.

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