Last active
October 30, 2016 18:44
-
-
Save alexpani/5220510 to your computer and use it in GitHub Desktop.
Woocommerce Mini Cart
This file contains 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 | |
/** Show item number on cart **/ | |
/* Uso: <?php minicart(); ?> */ | |
/* Plugin consigliato: WP PHP widget */ | |
function minicart( $echo = true ) { | |
global $woocommerce; | |
ob_start(); | |
// quantity | |
$qty = 0; | |
if (sizeof($woocommerce->cart->get_cart())>0) : foreach ($woocommerce->cart->get_cart() as $item_id => $values) : | |
$qty += $values['quantity']; | |
endforeach; endif; | |
if ( $qty == 1 ) | |
$label = __( 'Articolo nel carrello', 'yiw' ); | |
else | |
$label = __( 'Articoli nel carrello', 'yiw' ); ?> | |
<div id="minicart"> | |
<a class="widget_shopping_cart trigger " href="<?php echo $woocommerce->cart->get_cart_url() ?>"> | |
<div><span class="minicart"><?php echo $qty ?> <?php echo $label ?> </span></div> | |
</a></div> | |
<?php | |
$html = ob_get_clean(); | |
if ( $echo ) | |
echo $html; | |
else | |
return $html; | |
} |
This file contains 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
hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment