Untitled

mail@pastecode.io avatar
unknown
php
2 years ago
631 B
2
Indexable
Never
add_filter( 'woocommerce_add_to_cart_fragments', 'iconic_cart_count_fragments', 10, 1 );

function iconic_cart_count_fragments( $fragments ) {
    
	global $woocommerce;
	
	ob_start();

	?>

	<button class="xoo-wsc-cart-trigger"><?php $total = WC()->cart->get_total(  ); echo $total; ?><i class="eicon-cart-solid"></i><?php if ( $woocommerce->cart->get_cart_contents_count() >= 1 ): ?><div class="cart-bubble"><?php echo $woocommerce->cart->get_cart_contents_count(); ?></div><?php endif; ?></button>
    
    <?php
    $fragments['button.xoo-wsc-cart-trigger'] = ob_get_clean();
    
    return $fragments;
    
}