I'm trying to add a custom menu element to the WordPress navigation. I'm using Woocommerce plugin as well.
I'm using below code to add the menu element and it works fine but I can't get the get_cart_total()
showing just after the "Cart" text.
function add_menu_cart_wc($items, $args) {
if( $args->theme_location == 'primary' ){
$items .= '<li class="menu-item">'
. '<a href="'. wc_get_cart_url() .'">Cart "'. get_cart_total() .'"</a>'
. '</li>';
}
return $items;
}
add_filter('wp_nav_menu_items', 'add_menu_cart_wc', 10, 2);
Error I'm getting is Call to undefined function get_cart_total()
Thanks!