Hi
I have disabled the mini-cart from displaying on mobile devices. I didnt lik eit on small devices
However, there is now no way for mobile device users to view their cart from other pges on my website
As such, I would like to put a “View Cart” button on the main shop/product page
Firstly, Is that possible ?
Secondly, is there any way to have it show only if their is a product in the users cart ?
Thanks
Ivan
Hey ivanglaser,
Thanks for your question, to add a “view cart” button to your shop page only on mobile and only if there are products in the cart, try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:
function custom_view_cart_button() { ?>
<script>
(function($){
var width = $(window).width();
var add_cart_btn = '<div class="cart_btn" style="display:flex;justify-content:center;"><a href="/cart/" class="button wc-forward">View Cart</a></div>';
if ($('#top.woocommerce-shop .menu-item.cart_dropdown .av-cart-counter').hasClass('av-active-counter') && width <= 767) {
$(add_cart_btn).insertAfter( ".woocommerce-products-header" );
}
})(jQuery);
</script>
<?php
}
add_action('wp_footer', 'custom_view_cart_button');
Please see the screenshot in the Private Content area of the expected results.
I was not sure where you wanted the button so if you want it elsewhere let us know.
Best regards,
Mike
Fantastic. That works !
I really appreciate your help Mike. Thank you
Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.
Best regards,
Mike