Last updated on September 13, 2023

Remove WooCommerce Cart Icon From Header

Don’t know where to add this snippet? Read our guide: How to add code snippets.

Remove the WooCommerce cart icon.

The WooCommerce cart icon in the header is added by default to your site when you install and activate WooCommerce. However, in some cases, you may want to remove the WooCommerce cart icon from the header to simplify the design or layout of your site.

To remove the WooCommerce cart icon from the header, you can use the woocommerce_before_mini_cart action hook and the remove_action function. Here’s an example code snippet:

function wpsnippets_remove_woocommerce_cart_icon() {
    remove_action( 'woocommerce_before_mini_cart', 'woocommerce_mini_cart', 10 );
}

add_action( 'init', 'wpsnippets_remove_woocommerce_cart_icon' );

In this code snippet, we define a function wpsnippets_remove_woocommerce_cart_icon that uses the remove_action function to remove the woocommerce_mini_cart function from the woocommerce_before_mini_cart action hook. We hook this function to the init action, which ensures that it is loaded early enough to remove the cart icon before it is displayed.

You can modify the priority of the remove_action function to ensure that the cart icon is removed at the appropriate time, and you can use similar code to remove other elements from the WooCommerce shop pages. Additionally, you can modify the HTML and CSS of your site to adjust the layout of the header without the cart icon.

Last updated on September 13, 2023. Originally posted on May 9, 2023.

Leave a Reply

Your email address will not be published. Required fields are marked *