Website Building » WooCommerce » How Do I Add a Shopping Cart Icon to WooCommerce?

How Do I Add a Shopping Cart Icon to WooCommerce?

Last updated on December 24, 2022 @ 4:03 am

Adding a shopping cart icon to your WooCommerce store is a great way to increase the visual appeal of your site and make it more user-friendly. By default, WooCommerce does not include a shopping cart icon, but there are a few ways you can add one.

The easiest way to add a shopping cart icon to your WooCommerce store is to use a plugin. There are a number of plugins available that will add a shopping cart icon to your site, and many of them are free.

One popular option is the WooCommerce Menu Bar Cart plugin. Once you install and activate the plugin, a shopping cart icon will be added to your site’s menu bar.

PRO TIP: When adding a shopping cart icon to WooCommerce, be sure to add the correct code in the correct spot. Incorrectly adding code can break your site.

If you prefer not to use a plugin, you can also add a shopping cart icon to your WooCommerce store by editing your site’s code. This is a more advanced option and is not recommended for beginners. To do this, you will need to edit your site’s header.php file and add the following code:

<?php
if ( in_array( 'woocommerce/WooCommerce.php', 
apply_filters( 'active_plugins', get_option( 'active_plugins' ) 
) 
) 
) {
 
    $count = WC()->cart->cart_contents_count;
    ?><a class="cart-contents" 
      href="<?php echo WC()->cart->get_cart_url(); ?>" 
      title="<?php _e( 'View your shopping cart' ); ?>">
     
     <?php if ( $count > 0 ) { ?>
            <span class="cart-contents-count">
 
     <?php echo esc_html( 
          $count ); 
          ?></span>
        <?php } ?>
    </a>;
}?>

Once you have added this code, save the file and upload it to your server. A shopping cart icon should now appear on your site.

There are two ways that you can add a shopping cart icon onto your WooCommerce store – either through the use of plugins or by editing your site’s code. If you are inexperienced with coding, then we would recommend using one of the many plugins that are available as this is the easier method.

One popular plugin is the WooCommerce Menu Bar Cart plugin which is available for free. Simply install and activate the plugin and a shopping cart icon will be automatically added to your menu bar. If you prefer not to use a plugin or if you are more experienced with coding, then you can edit your header.php file and add the necessary code in order to display a shopping cart icon on your site.

Madison Geldart

Madison Geldart

Cloud infrastructure engineer and tech mess solver.