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.
Thank you to all of our customers!
- This topic has 39 replies, 3 voices, and was last updated 8 years, 10 months ago by
WC Vendors Support.
-
AuthorPosts
-
January 11, 2015 at 1:21 pm #2423
Jerry
ParticipantHi 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?
January 11, 2015 at 2:39 pm #2424WC Vendors Support
ParticipantOf course, there’s a Shortcodes article in the Knowledgebase. π
January 11, 2015 at 3:52 pm #2425Jerry
ParticipantWell 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?
January 11, 2015 at 3:56 pm #2426WC Vendors Support
ParticipantHi 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?
January 11, 2015 at 4:42 pm #2427Jerry
ParticipantHi 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?
January 11, 2015 at 4:55 pm #2428Jerry
ParticipantThis 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>January 11, 2015 at 5:24 pm #2429Jerry
ParticipantUser/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 π
January 11, 2015 at 11:53 pm #2430WC Vendors Support
ParticipantHere’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. π
January 12, 2015 at 2:42 am #2431Jerry
ParticipantHi 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!
January 12, 2015 at 10:07 am #2438WC Vendors Support
ParticipantLet’s say that the variable name for the vendor username is $username
January 12, 2015 at 3:16 pm #2447Jerry
ParticipantOk 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.
January 12, 2015 at 3:40 pm #2448WC Vendors Support
ParticipantIf 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….
January 12, 2015 at 3:45 pm #2449Jerry
ParticipantGot it! This is what I did: <?php echo do_shortcode(‘ [wcv_products vendor=”‘ .$userpro->id_to_member($user_id).'”]’ ); ?>
January 12, 2015 at 3:52 pm #2450WC Vendors Support
ParticipantPerfect! See? A nice built in function. π Great job.
January 30, 2015 at 10:13 am #2698Jamie
ParticipantHello!
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!
JamieJanuary 30, 2015 at 12:58 pm #2699WC Vendors Support
ParticipantHi Jamie,
Why not use the shortcodes? You can do_echo a shortcode in any template you wish……..
Ben
January 30, 2015 at 10:49 pm #2702Jamie
ParticipantHi 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!
January 30, 2015 at 11:11 pm #2703WC 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. π
January 30, 2015 at 11:34 pm #2704Jamie
ParticipantI must be missing something. It is still pulling all of the listings. Each listing owned by a different user or vendor.
January 30, 2015 at 11:36 pm #2705Jamie
ParticipantI’m using this within a geodirectory listing. Should I be looking to call the owner of the directory listing.instead of the author?
January 30, 2015 at 11:38 pm #2706WC Vendors Support
ParticipantWill repost in a sec, code got garbled while styling it.
January 30, 2015 at 11:41 pm #2709WC Vendors Support
Participanthttps://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.
January 30, 2015 at 11:46 pm #2710Jamie
ParticipantSame result but now I see the debug in the lislisting.
January 30, 2015 at 11:51 pm #2711WC Vendors Support
ParticipantOk, 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. π
January 31, 2015 at 12:02 am #2712Jamie
ParticipantHe 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
IDJanuary 31, 2015 at 12:07 am #2713WC Vendors Support
ParticipantThat’s easy then. π
January 31, 2015 at 12:07 am #2714WC Vendors Support
ParticipantPS — That’s one line of code, to replace them all. You wont need anything else in there.
January 31, 2015 at 12:17 am #2715Jamie
ParticipantOK,
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!
January 31, 2015 at 12:20 am #2716WC Vendors Support
ParticipantYou bet. Have fun. π
January 31, 2015 at 12:45 am #2717Jamie
ParticipantStill nothing. I cleared cache after setting the author. Im not sure what we could be missing??
January 31, 2015 at 12:47 am #2718WC Vendors Support
ParticipantTo keep going, supporting someone *elses* plugin for you, it’s $49 π
January 31, 2015 at 12:47 am #2719Jamie
ParticipantIt is actually placing the author name in the content area but not limiting the listings.
January 31, 2015 at 1:28 am #2720Jamie
ParticipantShouldnt 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.
January 31, 2015 at 6:08 pm #2728WC Vendors Support
ParticipantI 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.
January 31, 2015 at 6:30 pm #2729Jamie
ParticipantOk, would you be able to get it done today?
January 31, 2015 at 7:23 pm #2730WC Vendors Support
ParticipantPlease 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.
February 2, 2015 at 1:33 pm #2737Jamie
ParticipantWpgeodirectory.com
Ps..I’m still being blocked from your website from failed login attempts.
February 2, 2015 at 5:41 pm #2741WC Vendors Support
ParticipantEeek. 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.
February 2, 2015 at 7:14 pm #2742Jamie
ParticipantThanks 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?
February 2, 2015 at 7:37 pm #2744WC Vendors Support
ParticipantWell, 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.
-
AuthorPosts
- The forum ‘WC Vendors Free Support’ is closed to new topics and replies.