Is there any way to display the WooCommerce mini-cart on my WordPress site?
As Bhoomi suggested, using woocommerce_mini_cart();
works however ajax cart doesn't update the minit cart.
Using this method I suggest to wrap mini_cart function with "widget_shopping_cart_content" woocommerce class, for example :
<div class="widget_shopping_cart_content"><?php woocommerce_mini_cart(); ?></div>
So with ajax add to cart, the mini cart is updated also.
First Create the shortcode on function.php
// Add Shortcode
function custom_mini_cart() { echo '<a href="#" class="dropdown-back" data-toggle="dropdown"> '; echo '<i class="fa fa-shopping-cart" aria-hidden="true"></i>'; echo '<div class="basket-item-count" style="display: inline;">'; echo '<span class="cart-items-count count">'; echo WC()->cart->get_cart_contents_count(); echo '</span>'; echo '</div>'; echo '</a>'; echo '<ul class="dropdown-menu dropdown-menu-mini-cart">'; echo '<li> <div class="widget_shopping_cart_content">'; woocommerce_mini_cart(); echo '</div></li></ul>'; } add_shortcode( '[custom-techno-mini-cart]', 'custom_mini_cart' );
Then add this [custom-techno-mini-cart] short code anywhere on page.
Now add this inside your template
<?php echo do_shortcode(['custom-techno-mini-cart']); ?>
Hope This will help you.
Make your layout according to your requirement in first point.
ADD Like This ALSo using This
woocommerce_mini_cart()
You can use woocommerce_mini_cart()
wherever you want to display your minicart.
This function loads the mini-cart.php template to display the mini cart.