WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce Menu Cart
[resolved] Display In Admin Bar (17 posts)

  1. iamdhunt
    Member
    Posted 1 year ago #

    Is there a way that I can get the cart to show up in the wordpress admin bar, my site doesn't use the menus.

    http://wordpress.org/extend/plugins/woocommerce-menu-bar-cart/

  2. Jeremiah
    Member
    Plugin Author

    Posted 1 year ago #

    Hello! Are you talking about displaying it as a widget in the sidebar? Could you post a link to your site so I can better understand what you're referring to? Thanks!

    Jeremiah

  3. iamdhunt
    Member
    Posted 1 year ago #

    Yep: http://livinglifefearless.com/, it's the user bar at the top.

  4. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    Try the following:

    add to __construct:

    add_action('admin_bar_menu', array( &$this, 'add_toolbar_wcmenucart' ), 100);

    then add the function:

    public function add_toolbar_wcmenucart($admin_bar){
    		if (!is_admin()) {
    			$dom = new DOMDocument();
    			$dom->loadHTML($this->wcmenucart_menu_item());
    
    			foreach ($dom->getElementsByTagName('a') as $a) {
    			    $menutitle = $a->nodeValue;
    				$menuhref = $a->getAttribute('href');
    			}
    
    			$admin_bar->add_menu( array(
    				'id'    => 'wcmenucart',
    				'title' => '<i class="wcmenucart-icon-shopping-cart-0"></i>'.$menutitle,
    				'href'  => $menuhref,
    				'meta'  => array(
    					'title' => __('View your shopping cart', 'wcmenucart'),
    				),
    			));
    		}
    	}

    should work

  5. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    btw, this doesn't take your setting for the cart icon into account, just delete the <i> element from the title if you don't want it (dom doesn't support innerHTML, which makes it a bit harder to include the whole menu item)

  6. iamdhunt
    Member
    Posted 1 year ago #

    This all goes in my functions.php correct?

  7. Jeremiah
    Member
    Plugin Author

    Posted 1 year ago #

    Actually, you'll want to add that to the plugin itself. If you open the menu cart plugin's main php file you'll be able to see where you need to place the filter and the function. Let us know if you need any more help with this.

  8. iamdhunt
    Member
    Posted 1 year ago #

    Thanks! Works great. Only thing is that fly out doesn't work. If it's not possible that understandable, great plugin anyways.

  9. iamdhunt
    Member
    Posted 1 year ago #

    Actually I also just noticed that in my footer I'm getting this error:

    Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Empty string supplied as input in /woocommerce-menu-cart-pro/woocommerce-menu-cart-pro.php on line 67

    Any ideas on why?

  10. Jeremiah
    Member
    Plugin Author

    Posted 1 year ago #

    Hey there! I just checked your site and I don't see it active. We can't trouble shoot the flyout without being able to see it on your site. My guess is that it has to do with the fact that your menu is the admin menu instead of the standard WP menu. As far as error in your footer, you could try commenting out or deleting line 67: load_plugin_textdomain( 'wcmenucart', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );

    Again, it's probably because this is being loaded via the admin menu instead of the standard wp menu. That particular line just loads other language translations, but I'm guessing your site will be in English, correct?

  11. iamdhunt
    Member
    Posted 1 year ago #

    Oh sorry it's active again and the error has seemed to have gone away, and yes it will be in english so language translations isn't much of a concern for me right now.

    http://livinglifefearless.com

  12. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    I'm guessing that your line 67 is not the language but the custom function I posted. I have no idea what could have caused the error, let us know when it comes back.

    Unfortunately it's not possible to enable the flyout in the admin bar the way the plugin is currently setup & how the WP admin bar interface works.

    Thanks for purchasing the pro version by the way, I couldn't tell from your username :)
    If you need more in depth support, do not hesitate to contact us on support@wpovernight.com, as this forum is mainly about the free version.

  13. iamdhunt
    Member
    Posted 1 year ago #

    Yeah it's the custom function that's causing the error and it's popped up again. You can see it at the bottom of the site.

  14. Ewout
    Member
    Plugin Author

    Posted 1 year ago #

    Possibly this is because you don't have the 'always display' setting enabled: the error disappears when I add something to the cart.

    You could try to replace this (first line in the custom function):

    if (!is_admin()) {

    with this:

    if (!is_admin() && $this->wcmenucart_menu_item() != '') {

    let me know if this solves the error for you!

  15. iamdhunt
    Member
    Posted 1 year ago #

    You were correct not having it always displayed was causing the error. But that fixed the problem. Thanks!

  16. Jeremiah
    Member
    Plugin Author

    Posted 1 year ago #

    Great! I'd say this is resolved then. Let us know if you have any other questions. :)

  17. Ewout
    Member
    Plugin Author

    Posted 7 months ago #

    For anyone reading this, I rewrote this solution so that you don't need to modify any core plugin files, but add the code to functions.php instead: http://wordpress.org/support/topic/use-in-admin-bar?replies=4#post-5067921

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic