I've been trying to implement the MiniCart in my woocommerce shop, yet without succes.
What I tried is making a custom function and shortcode, and call it in my header.
Here's the code I'm using in my theme functions:
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( '[nachtleven-mini-cart]', 'custom_mini_cart' );
So I want to use this to output the mini cart:
<?php echo do_shortcode('nachtleven-mini-cart'); ?>
Yet it always returns a string on the frontend: [custom-mini-cart]
, so it seems like the shortcode isn't working. Am I missing something here? Even a simple echo in the function won't display.
I haven't had any problems with making and using shortcodes before, though this is the first time I'm building with WooCommerce.
Any help or tips would be greatly appreciated as I'm kinda overlooking the problem here.
Thanks =)