Skip to content

Instantly share code, notes, and snippets.

@amielucha
Created May 2, 2018 15:15
Show Gist options
  • Select an option

  • Save amielucha/4462c73485c44a8c2a7a49a31c6be075 to your computer and use it in GitHub Desktop.

Select an option

Save amielucha/4462c73485c44a8c2a7a49a31c6be075 to your computer and use it in GitHub Desktop.
Font Awesome 5 cart with a WooCommerce counter - action
<?php
// Place in an action.
// Requires Font Awesome 5.
function cs_cart_icon() {
// Bail early if we don't have WC.
if ( !function_exists('wc_get_cart_url') ) return;
?>
<a class="cart-contents text-white" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View the shopping cart' ) ?>">
<span class="fa-layers fa-2x fa-fw">
<i class="fas fa-shopping-cart"></i>
<span class="fa-layers-counter bg-secondary" data-fa-transform="grow-20"><?php echo WC()->cart->get_cart_contents_count() ?></span>
</span>
</a>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment