What is the best way to include mini cart on woocommerce


#1

What is the best to to add/include mini cart drop down is it by getting a plugin or custom made?

i mean what is the way that themes use.


#2

Hi there,

Custom made is really easy :wink: Here is an example for the dropdown content that you can trigger with Jquery :

/* Custom Shoping Cart in the top */
	function YOURTHEME_wc_print_mini_cart() {
		?>
		
<?php if ( sizeof( WC()->cart->get_cart() ) > 0 ) : ?>
    <?php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) : $_product = $cart_item['data']; // Only display if allowed if ( ! apply_filters('woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) || ! $_product->exists() || $cart_item['quantity'] == 0 ) continue; // Get price $product_price = get_option( 'woocommerce_tax_display_cart' ) == 'excl' ? $_product->get_price_excluding_tax() : $_product->get_price_including_tax(); $product_price = apply_filters( 'woocommerce_cart_item_price_html', woocommerce_price( $product_price ), $cart_item, $cart_item_key ); ?>
  • <?php echo $_product->get_image(); ?>

    <?php echo apply_filters('woocommerce_widget_cart_product_title', $_product->get_title(), $_product ); ?>

    <?php echo apply_filters( 'woocommerce_widget_cart_item_price', '' . __('Unit Price', 'YOURTHEME') . ':' . $product_price . '', $cart_item, $cart_item_key ); ?> <?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '' . __('Quantity', 'woffice') . ':' . $cart_item['quantity'] . '', $cart_item, $cart_item_key ); ?>
  • <?php endforeach; ?>
<?php else : ?>

<?php _e( 'No products in the cart.', 'YOURTHEME' ); ?>

<?php endif; ?> <?php if (sizeof( WC()->cart->get_cart()) > 0) : ?>

<?php _e( 'Cart Subtotal', 'YOURTHEME' ); ?>: <?php echo WC()->cart->get_cart_subtotal(); ?>

<?php endif; ?>
<?php }

To ajaxify the cart icon/total : http://docs.woothemes.com/document/show-cart-contents-total/

I hope that helps, otherwise there is many other answers on Stackoverflow I think.

Regards,

2F