Last active
August 29, 2015 14:18
-
-
Save trys/94ce98ec8a2003a09f1f to your computer and use it in GitHub Desktop.
Top Cart
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
<?php | |
/** | |
* Ajax top-cart | |
* | |
* @param array $fragments | |
* @return array | |
*/ | |
function projectnamespace_woocommerce_ajax_top_cart( $fragments ) { | |
ob_start(); | |
get_template_part( 'views/top-cart' ); | |
$fragments['div.top-cart'] = ob_get_clean(); | |
return $fragments; | |
} | |
add_filter( 'add_to_cart_fragments', 'projectnamespace_woocommerce_ajax_top_cart' ); | |
/* ----- */ | |
global $woocommerce; | |
if ( $woocommerce ) : ?> | |
<div class="top-cart"> | |
<a class="top-cart__account" href="<?php echo get_permalink( 22 );?>"><i class="fa fa-user"></i> MY ACCOUNT</a> | |
<a class="top-cart__basket" href="<?php echo WC()->cart->get_cart_url(); ?>"> | |
<small><?php echo sprintf( _n( '%d ITEM', '%d ITEMS', $count = WC()->cart->get_cart_contents_count() ), $count )?></small> | |
<strong><?php echo wc_price( WC()->cart->subtotal ); ?></strong> | |
</a> | |
</div> | |
<?php endif;?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment