Viewing 9 replies - 1 through 9 (of 9 total)
  • I got here from google, and found your link ( THANK YOU )

    in case you didn’t get it to work, or anyone came from google, here is how :

    you have to declar this first : <?php global $woocommerce; ?> //required !!!!

    And then put this wherever you want the total number of items to appear :

    <?php echo sprintf(_n(‘%d item’, ‘%d items’, $woocommerce->cart->cart_contents_count, ‘woothemes’), $woocommerce->cart->cart_contents_count);?>

    if someone want to print the total ( $ ) like me you can put this code :

    <?php echo $woocommerce->cart->get_cart_total(); ?>

    and here is the cart url too :
    <?php echo $woocommerce->cart->get_cart_url(); ?>

    So play with this as you see fit , any questions please do ask ??

    Thank you again croberts1

    and where did you declare this global variable,btw ?

    I’m trying to make the cart a main menu item (up next to login) and stick the number of items in the cart in there.

    you declare it where ever you want, just make sure it’s first before any code that depends on it… i.e : <?php echo sprintf(_n(‘%d item’, ‘%d items’, $woocommerce->cart->cart_contents_count, ‘woothemes’), $woocommerce->cart->cart_contents_count);?>

    Ah yes. The issue I am having is we have put “cart” as a menu item in the top sitenav menu in the “whitelight commerce” theme.

    How could I get the cart item count in that menu.. It’s not so easily accessible. is a javascript update going to be the easiest way to get it in there?

    I suggest you don’t put Cart with wordpress menu, you put the native menu items, and code the menu item “cart” after that…

    I have been given a pretty specific design spec from my client. If there is some way to get it in there I’d like to do it. Would perhaps a small custom plug-in handle it or something like that?

    Right now the menu is.. “My Account Cart Checkout Logout”

    I just want to make it so that the it reads:

    “My Account Cart (3 items) Checkout Logout”

    Possible?

    It seems what I might need is a “custom walker” going to see what I can discover about creating something like this..

    after alot of research learning about how wordpress builds its menus I came up with an extension to the walker class that goes like this:

    https://pastebin.com/maQ2Xnjg

    works like a charm

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘WooCommerce Cart Total’ is closed to new replies.