mardi 9 avril 2019

Use an If statement as the card if empty woocommerce

I have a bootstrap pill inside my menu with the cart count. But I don't want to show the pill when the card is empty. How can I hide this with an If statement inside my walker menu.

<?php
wp_nav_menu( array(
'theme_location'  => 'primary',
'menu_id'         => 'primary-menu',
'container'       => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id'    => 'navbarsExampleDefault',
'menu_class'      => 'navbar-nav ml-auto',
'fallback_cb'     => '__return_false',
'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s

<li class="nav-item language">
<a class="" href="'.wc_get_cart_url().'"><img class="icon-card" src="card-logo.svg"><span class="badge badge-pill badge-oranje">'.sprintf ( _n( '%d', '%d', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ).'</span></a>
<a class="" href=""><img class="icon-card" src="vlag-nl.svg"></a>
<a class="" href=""><img class="icon-card" src="vlag-uk.svg"></a>
</li>
</ul>',
'depth'           => 3,
'walker'          => new wp_bootstrap_navwalker()
) );
?>

</div>

and the if statement

<?php
if ( WC()->cart->get_cart_contents_count() != 0 ) {
       echo 'niet leeg';
}?>

Aucun commentaire:

Enregistrer un commentaire