Last active
August 29, 2019 06:02
-
-
Save ronipl/6b08a194b05ce50a8eaedf76e12a3052 to your computer and use it in GitHub Desktop.
woo commerce cart icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//header.php | |
(function($){ | |
$(document).ready(function(){ | |
var cart_count = $('.cart-customlocation').text(); | |
var cart_element = `<span>${cart_count}</span>`; | |
var cart_menu = $("#menu-user-menu").children('li:first-child').find('a'); | |
$(cart_menu).find('span').remove(); | |
$(cart_menu).append(cart_element); | |
}); | |
})(jQuery); | |
<a class="cart-customlocation" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>" style="display:none;"><?php echo sprintf ( _n( '%d', '%d', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?></a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment