ankara escort bayan ankara escort bayan ankara escort
Display WooCommerce Cart Content and Cart Total Amount Archives - Wpdevcodes
sakarya escort sakarya escort sakarya escort bayan sakarya escort bayan serdivan escort kayseri escort webmaster forum

Tag Archives: Display WooCommerce Cart Content and Cart Total Amount

Woocommerce add to cart count can allow to display in the Header section. In this article we can know how to display the cart count in the header. Here is the code, add the below code in the function.php file.

<?php 
add_filter('add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
function woocommerce_header_add_to_cart_fragment( $fragments ) {
	global $woocommerce; ob_start(); ?>
	<a class="cart" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo $woocommerce->cart->cart_contents_count; ?></a>
	<?php $fragments['a.cart'] = ob_get_clean(); return $fragments; } ?>
	<a class="cart-contents" 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>