shshanker
12/1/2015 - 7:38 AM

Woocommerce Mini-Cart

Woocommerce Mini-Cart

<?php
// on header
<?php global $woocommerce; ?>
	<a class="cart-contentsdasdasds" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>


// on functions.php

	
	
public function woocommerce_header_add_to_cart_fragment( $fragments ) {
			global $woocommerce;
			ob_start();
			?>
			<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
			<?php

			$fragments['a.cart-contentsdasdasds'] = ob_get_clean();

			return $fragments;

			}
			
			// Filters 
		add_filter('add_to_cart_fragments', array( $this, 'woocommerce_header_add_to_cart_fragment'));

?>