Skip to content

Instantly share code, notes, and snippets.

@yuliyang
Last active November 8, 2021 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuliyang/beab97d0ef07dd570a9d6022d60237eb to your computer and use it in GitHub Desktop.
Save yuliyang/beab97d0ef07dd570a9d6022d60237eb to your computer and use it in GitHub Desktop.
[WooCommerce] Cart Total Shortcode
<?php
// Allow shortcode in nav items
add_filter('wp_nav_menu_items', 'do_shortcode');
// [cart-total]
add_shortcode( 'cart-total', 'ching_shortcode_woo_cart_total' );
function ching_shortcode_woo_cart_total(){
$total = WC()->cart->total;
return '<span>'.wc_price($subtotal).'</span>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment