Add Cart icon to Navigation
-
I’d like to add a Cart icon to my child theme, since it’s a WooCommerce site. but I don’t see anything in the settings to add one.
I tried to add the following function but it didn’t take:
/** * Create Shortcode for WooCommerce Cart Menu Item */ function woo_cart_but() { ob_start(); $cart_count = WC()->cart->cart_contents_count; // Set variable for cart item count $cart_url = wc_get_cart_url(); // Set Cart URL ?> <li><a class="menu-item cart-contents" href="<?php echo $cart_url; ?>" title="My Basket"> <?php if ( $cart_count > 0 ) { ?> <span class="sr-only">Cart</span><span class="cart-contents-count"><?php echo $cart_count; ?></span> <?php } ?> </a></li> <?php return ob_get_clean(); } /** * Add WooCommerce Cart Menu Item Shortcode to particular menu */ function woo_cart_but_icon ( $items, $args ) { $items .= '[woo_cart_but]'; // Adding the created Icon via the shortcode already created return $items; }
- The topic ‘Add Cart icon to Navigation’ is closed to new replies.