To hide the “View Cart” button in the WooCommerce mini cart, you can use some custom CSS. You can add this CSS to your theme’s stylesheet, or you can use a plugin like “Simple Custom CSS” to add it to your site.
Here’s the CSS that you can use to hide the “View Cart” button:
.woocommerce .widget_shopping_cart .buttons a.button.wc-forward {
display: none !important;
This CSS selector targets the “View Cart” button specifically, and sets its display property to “none” to hide it. The !important
flag is added to ensure that this styles overwrite any other styles that might be affecting the button.
You should be careful when modifying your CSS, as it can have unintended consequences. If you’re not comfortable making changes to your site’s code, you may want to consult a developer to help you with this task.
Additionally you could use javascript code to hide the button by adding code to your theme’s javascript file, or by using a plugin like “Custom JS and CSS”.
document.querySelector('.woocommerce .widget_shopping_cart .buttons a.button.wc-forward').style.display = "none";
This script will target the button using the same selector as the CSS version, and set the display style of the selected element to “none”.
Another way to hide the “View Cart” button in the WooCommerce mini cart is by using a filter in your theme’s functions.php file. This method allows you to make the change to your site’s code without modifying the theme’s stylesheet directly.
You can use the woocommerce_widget_shopping_cart_buttons
filter to modify the buttons that are displayed in the mini cart. Here’s an example of how you can use this filter to remove the “View Cart” button:
add_filter('woocommerce_widget_shopping_cart_buttons', 'remove_view_cart_button', 10, 1);
function remove_view_cart_button($buttons) {
unset($buttons['view_cart']);
return $buttons;
}
This code adds a new function remove_view_cart_button
that hooks into the woocommerce_widget_shopping_cart_buttons
filter and modifies the $buttons argument passed to the filter. The function unset
the ‘view_cart’ from the buttons array, this will make the button disappear from the mini cart.
You should be careful when modifying your functions.php file, as a small mistake in this file can cause your site to stop working. It is important to have a backup of your website and make sure that you test the changes in a staging or development environment before applying to a live site.
Relative blog : How To Change Return To Shop Link in woocommerce | Geekerhub