Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adding WooCommerce cart link to wp_nav_menu()
<?php
function my_nav_wrap() {
$wrap = '<ul id="%1$s" class="%2$s">';
$wrap .= '%3$s';
$wrap .= '<li class="cart">';
$wrap .= '<a href="' . WC()->cart->get_cart_url() . '"> class="cart_totals">';
$wrap .= WC()->cart->get_cart_total();
$wrap .= '</a>';
$wrap .= '</li>';
$wrap .= '</ul>';
return $wrap;
}
<nav>
<?php wp_nav_menu(array(
'theme_location' => 'my_menu_location',
'items_wrap' => my_nav_wrap()
)); ?>
</nav>
@NickToye

This comment has been minimized.

NickToye commented Mar 8, 2016

Hi,

This doesn't work. It prints out > class="cart_totals">

@loversjain

This comment has been minimized.

loversjain commented Jun 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment