Last active
November 8, 2021 13:31
-
-
Save yuliyang/beab97d0ef07dd570a9d6022d60237eb to your computer and use it in GitHub Desktop.
[WooCommerce] Cart Total Shortcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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