Because this functionality is hard-baked into the JS of WooCommerce, you can’t disable it with a filter or hook. However, after trawling through WC’s code, I discovered a handy (and slightly hacky) caveat:
If you add the following empty div to the same container as your Add to Cart button, the View Cart (or View Basket if you’re in the UK) link won’t get added:
<div class="added_to_cart"></div>
This is because the Javascript file checks to see if an element with that class already exists:
If it finds an existing .added_to_cart element, it won’t try to append another.
It’s worth noting that Sathyanarayanan G’s answer should totally work too (and I’m surprised it didn’t – that sort of points to something else being wrong), but in a slightly different way.
Other thing not related to this OP question. If you want to remove the “View Cart” button after item(s) has been removed from mini cart, you can add another jQuery function, but this should not be placed in no_view_cart() function:
Because this functionality is hard-baked into the JS of WooCommerce, you can’t disable it with a filter or hook. However, after trawling through WC’s code, I discovered a handy (and slightly hacky) caveat:
If you add the following empty div to the same container as your Add to Cart button, the
View Cart
(orView Basket
if you’re in the UK) link won’t get added:<div class="added_to_cart"></div>
This is because the Javascript file checks to see if an element with that class already exists:
If it finds an existing
.added_to_cart
element, it won’t try to append another.It’s worth noting that Sathyanarayanan G’s answer should totally work too (and I’m surprised it didn’t – that sort of points to something else being wrong), but in a slightly different way.
I think this may be useful.
Just add this code in css.
Adding the below line of code to your child theme’s style.css should do the trick.
That will do the job (but its not the ideal solution)
If you want to keep the “Add To Cart” button and remove the “View Basket”
This is code for change name of view cart button text and change button URL.
Code goes in function.php file of your active child theme (or theme). Tested and works.
Please do not change any code into the add-to-cart.js file.
Otherwise its not work.
Any help would be greatly appreciated.
Adding this to style.css in child theme worked for me.
Sorry for not having explanation. Add to functions.php the following lines
Other thing not related to this OP question. If you want to remove the “View Cart” button after item(s) has been removed from mini cart, you can add another jQuery function, but this should not be placed in no_view_cart() function: