Skip to content

Instantly share code, notes, and snippets.

@DanielSantoro
Last active December 22, 2017 17:12
Show Gist options
  • Select an option

  • Save DanielSantoro/1d0dc206e242239624eb71b2636ab148 to your computer and use it in GitHub Desktop.

Select an option

Save DanielSantoro/1d0dc206e242239624eb71b2636ab148 to your computer and use it in GitHub Desktop.
Show Number of items in Cart and Subtotal (insert into template)
// Use in conjunction with https://gist.github.com/DanielSantoro/948c5000850c4695f30db8542f8bc966
<a class="cart-customlocation" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
@DanielSantoro
Copy link
Copy Markdown
Author

Hi there! You need to add Ajax to your custom cart display, which can be done with the snippet here: https://gist.github.com/DanielSantoro/948c5000850c4695f30db8542f8bc966

Basically, it won't update as needed until that Ajax code is paired with it, but after that it updates using the same values as a mini cart in Storefront or something like that. Hope this helps. :)

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