Home Forums WC Vendors Pro Support putting dashboard into buddypress

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 28 posts - 1 through 28 (of 28 total)
  • Author
    Posts
  • #10726
    Laurie
    Participant

    Hi,

    Im trying to intergrate wc vendors into buddypress.

    I’ve created a tab and I’m having great difficulty getting the dashboard to show up within that tab with decent formatting. I was wondering if I could use

    <?php echo do_shortcode('[wcv_pro_dashboard]'); ?>

    in the profile tab/page I’ve created And then manually set the address of the Pro Dashboard Page. using php to fetch the username and insert it in the profile address. However I’m unsure how and where to return the value. As far as I can understand the function I need to edit is the one below?

    Would it be as simple as just forming the web address and returning it.

    Any help greatly appreciated.

    public static function create_page( $slug, $page_title = '', $page_content = '', $post_parent = 0 ) {

    global $wpdb;

    $slug = "http://www.redstow.com/members/lauriedugdale/Vendor/"

    $page_id = WC_Vendors::$pv_options->get_option( $slug . '_page_id' );

    if ( $page_id > 0 && get_post( $page_id ) ) {
    return $page_id;
    }

    $page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", $slug ) );

    if ( $page_found ) {
    if ( !$page_id ) {
    WC_Vendors::$pv_options->update_option( $slug . '_page_id', $page_found );

    return $page_found;
    }

    return $page_id;
    }

    $page_data = array(
    'post_status' => 'publish',
    'post_type' => 'page',
    'post_author' => 1,
    'post_name' => $slug,
    'post_title' => $page_title,
    'post_content' => $page_content,
    'post_parent' => $post_parent,
    'comment_status' => 'closed'
    );

    $page_id = wp_insert_post( $page_data );

    WC_Vendors::$pv_options->update_option( $slug . '_page_id', $page_id );

    return $page_id;

    } //create_page()

    #10727
    WC Vendors Support
    Participant

    The Shortcode isnt going to work. It relies upon a set page for the Dashboard (aka a standard URL’s Permalink) and none of the buttons will work.

    What I would suggest, instead, is you add a link to the Pro Dashboard from the BuddyPress menu. There’s functions to add things to the BP menus using the filter “bp_member_options_nav” ( https://codex.buddypress.org/themes/members-navigation-menus/ )

    It’s a very simple filter to write, and since it’s so easy, I wrote one just for you right now. Give it a shot.

    https://gist.github.com/bentasm1/8a7bf992675f3b9cc400

    #10743
    Laurie
    Participant

    Hi,

    Thanks, will give that a go!

    However would it not be possible to put something like the code below into one of the admin functions to provide the link? Or does it not work like that?


    global $current_user;
    get_currentuserinfo();
    return 'http://www.redstow.com/members/' . $current_user->user_login . "/vendordashboard/";

    #10756
    WC Vendors Support
    Participant

    Unfortunately, no, that would not work. 🙁

    #10770
    Laurie
    Participant

    Hmm ok,

    Well for now I’ve used an Iframe to embed it within the buddypress profile. It looks good, but its a messy solution.

    #10772
    WC Vendors Support
    Participant

    That’s a clever trick. Even if it’s a bit messy, if it works, roll with it! 🙂 If you’d like to share how you did it, I’d be happy to create a KnowledgeBase article for other members to benefit from too.

    #10776
    Laurie
    Participant

    I’m not particularly advanced with php however I put the following code inside my functions.php file


    function add_dashboard_tabs() {

    if (class_exists('WC_Vendors')) {
    $wcv_profile_id = bp_displayed_user_id();
    $wcv_profile_info = get_userdata( bp_displayed_user_id() );

    //checking if user is a vendor and is viewing their own profile
    if ( $wcv_profile_info->roles[0] == "vendor" && bp_is_my_profile() == true ) {
    global $bp;

    bp_core_new_nav_item( array(
    'name' => 'Dashboard',
    'slug' => 'Dashboard',
    'parent_url' => $bp->displayed_user->domain,
    'parent_slug' => $bp->profile->slug,
    'screen_function' => 'dashboard_screen',
    'position' => 200,
    'default_subnav_slug' => 'Dashboard'
    ) );

    }
    }
    }
    add_action( 'bp_setup_nav', 'add_dashboard_tabs', 100 );

    function dashboard_screen() {
    add_action( 'bp_template_content', 'dashboard_screen_content' );
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }

    function dashboard_screen_content() {

    ?>
    <div id="my-div">
    //alter web adress so it links to the dashboard on your site
    <iframe src="http://www.redstow.com/dashboard/" id="my-iframe" scrolling="no"></iframe>
    </div>
    <?php

    }

    Use the following css but alter to suit your layout in order to get the iframe to show just the dashboard. on the dashboard page I removed all elements except the dashboard, you might want to do the same.


    #my-div
    {
    width : 100%;
    height : 1500px;
    overflow : hidden;
    position : relative;
    }

    #my-iframe
    {
    position : absolute;
    top : 0px;
    left : 0px;
    width : 1280px;
    height : 1200px;
    }

    #10779
    Laurie
    Participant

    sorry for some reason it added html to my code?

    #10783
    WC Vendors Support
    Participant

    Whenever you want to paste code, use pastebin or gist.github.com and just add a link here, it’ll auto add it to your post and format it properly. 🙂

    The dashboard is begin rewritten right now, is nearly complete, to remove all foundation css from it so that there are no weird layouts or conflicts. This will be in v1.0.2 due really really soon. 🙂

    #10784
    Laurie
    Participant

    Thanks! Will do that in future!

    Looking forward to v1.0.2 I have a growing list off css changes!

    #10785
    WC Vendors Support
    Participant

    Hopefully you won’t need any of the css changes when 1.0.2 is ready. 😉

    #12211
    mc24
    Participant

    Hi ben, Hi Laurie, Like you Laurie I have the kleo theme and I managed in 3 minutes to integrate the WC pro dashboard in buddy press profile menu with the plugin : BuddyPress Custom Profile Menu. Hope this will help. Now, I am trying to integrate the vendors products anyone would know how to do?
    Thanks

    #12220
    Anna
    Member

    @mc24
    This may be helpful to you. I’ve used a customized version of this on my site. https://gist.github.com/digitalchild/5ff5bf34571a4adef995#file-gistfile1-php

    #12221
    mc24
    Participant

    Thank you anna for your help. Unfortunately it has never worked. I tried many times. What I managed to, is create a page with product with shortcodes
    [wcv_recent_products vendor=”VENDOR-LOGIN-NAME” per_page=3]

    [wcv_products vendor=”VENDOR-LOGIN-NAME”]

    [wcv_featured_products vendor=”VENDOR-LOGIN-NAME”]

    It works as I have a product tab on buddy press but it does show all the store’s products and not just one vendor’s product. I might have a problem…

    And even in the page I created, it shows me all the products and not only just one vendor’s.

    #12223
    Anna
    Member

    Hmmmm. that’s weird that it does not work for you. 🙁
    I also use the same theme as you are using, and I have it integrated well with a fontello icon and everything on the member’s BP profile page. It is a new “tab” icon that when selected it will show that vendor’s products.

    Let me check my code and see if I had to alter anything to get it to work….

    #12224
    Anna
    Member

    Ahhh it may need to be changed a bit with PRO. I haven’t fully integrated with Pro yet since there are still some stying issues I am having and I am waiting for the next “patch” to see if the issues are fixed.

    So….. if it is trying to find the free Wc Vendor shop pages it might not work. I’m not sure yet if any of those lines need to be slightly changed with the Pro enabled.

    In addition, I remember not being able to get it to work by placing it in my bp files so I just put it in my child theme functions.php and it works fine.

    #13912
    Mark
    Participant

    MC24, I am trying to do something very similar as you. I have KLEO, PmPro, buddypress, and WC Vendors Pro.

    I used BuddyPress Custom Profile Menu plug, added a tab pointing to a page with the shortcode [wcv_products vendor=”VENDOR-LOGIN-NAME”], but just like you it shows all of the products created on my site and not just the products for that particular Buddypress Member profile I am viewing.

    Did you find a way to filter out all products from displaying that were not created by the current buddypress member profile we are viewing?

    #13922
    WC Vendors Support
    Participant

    @mtgame21 — Make sure the vendor-login-name is the user_login of the vendor. As an example, if you were a vendor here, you would be vendor=”mtgame21″

    If that doesnt work, create a test page with the shortcode. If it works there, something in Buddypress might be screwing up the shortcode arguments somehow.

    Ben

    #20113
    Laurie
    Participant

    Hi,

    Just revisiting this issue and wondering if there is a way to edit the “Pro Dashboard Page” setting to allow a php variable like below.

    
    $getusername = bp_get_displayed_user_username();
    return 'http://www.redstow.com/members/' . $getusername . "/dashboard/";
    
    #20115
    WC Vendors Support
    Participant

    Nope

    #20132
    Laurie
    Participant

    I’ll stick with an Iframe for now, incase anyone is following I’m using the code below. I’ve put the dashboard on a completely blank page with no other elements. I’ve also used JS in order to adjust the iframe according to the size of the dashboard.

    
    // add dashboard tab to buddypress
    function add_dashboard_tabs() {
        
    	if (class_exists('WC_Vendors')) { 
    		$wcv_profile_id = bp_displayed_user_id();
    		$wcv_profile_info = get_userdata( bp_displayed_user_id() );    
            
            //checking if user is a vendor and is viewing their own profile
            if ( $wcv_profile_info->roles[0] == "vendor" && bp_is_my_profile() == true ) { 
                global $bp;
    
                bp_core_new_nav_item( array(
                    'name'                  => 'Dashboard',
                    'slug'                  => 'Dashboard',
                    'parent_url'            => $bp->displayed_user->domain,
                    'parent_slug'           => $bp->profile->slug,
                    'screen_function'       => 'dashboard_screen',			
                    'position'              => 200,
                    'default_subnav_slug'   => 'Dashboard'
                ) );
    
            }
        }
    }
    add_action( 'bp_setup_nav', 'add_dashboard_tabs', 100 );
    
    function dashboard_screen() {
        add_action( 'bp_template_content', 'dashboard_screen_content' );
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }
    
    function dashboard_screen_content() { 
    
        ?> 
    
        <div id="my-div">
            <!-- put your url here -->
            <iframe src="http://www.your-dashboard-url-here.com/dashboard/" width="100%" height="200px" id="iframe1" marginheight="0" frameborder="0" onLoad="autoResize('iframe1');"></iframe>
        </div>
        <?php
    }
    

    JS i’m using

    
    function autoResize(id){
        var newheight;
        var newwidth;
    
        if(document.getElementById){
            newheight = document.getElementById(id).contentWindow.document .body.scrollHeight;
            newwidth = document.getElementById(id).contentWindow.document .body.scrollWidth;
        }
    
        document.getElementById(id).height = (newheight) + "px";
        document.getElementById(id).width = (newwidth) + "px";
    }
    
    #23193
    Magnus
    Participant

    Just reopening:

    Would it be possible, to hook into the code of WC Vendor, and change the button links and so on, so it would fit with a buddy press profile integration?

    Just a simple question, I dont know much about php.

    #23201
    WC Vendors Support
    Participant

    It’s possible to do anything, just a matter of how to code it. If you want to create your own button links, probably easier to just write the button links instead of re-sorting ours.

    #23207
    Magnus
    Participant

    I see – would the shortcode way, then work? If I did the button links aswell?

    #23209
    WC Vendors Support
    Participant

    The shortcode for the Pro Dashboard will only work on the page that has the shortcode, AND is also configured to be the page in wp-admin > WooCommerce > WC Vendors > Pro > Pro Dashboard Page. It cant be used as a standalone shortcode anywhere you want, that page *must* be set. It all comes down to dynamic URL rewrites.

    All of the links on the dashboard pages never change, it just shows you what you configure it to show. e.g., /dashboard/product for products, /dashboard/order for orders, etc… So if you want to build your own menu bar, just design it with the links to the dashboard as you see fit.

    Integrating the Pro Dashboard page to show within BuddyPress member pages (aka /members/ben/dashboard/) is not currently possible, and I dont think we have any plans to add features for that in the future.

    #23214
    Magnus
    Participant

    As mentioned it kindof worked, so far. As you say, everything can be done in matter of coding. 🙂

    #23344
    Laurie
    Participant

    Hi, Could you tell me how you’re displaying the products on the products dashboard page? I’m finding it hard to work out.

    Thanks!

    #27219
    Konrad Sroka
    Participant

    @magnuspil @Parousia

    Hey guys we just released a FREE WordPress plugin to

    add the WC Vendors Dashboard into BuddyPress profiles!

    Download directly from your WP admin, just search for “BP WC Vendors”

    Visit plugin page at WordPress.org
    https://wordpress.org/plugins/bp-wc-vendors/

    😉 cheers, konrad

    • This reply was modified 6 years, 10 months ago by Konrad Sroka.
Viewing 28 posts - 1 through 28 (of 28 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.
This website uses cookies to ensure you get the best experience on our website.