如果购物车中有1件或更多商品,我如何才能显示购物篮通知?

I have a call for the total price of the users cart to appear in the header but I only want it to be shown if there are 1 or more items in the users cart. Does anyone know what I need to add to the code to do this? I have tried a few suggestions I've found online but none has worked.

This is my current HTML code (that doesn't work):

     <?php if ( $cart_contents_count > 0 ) { ?>
        <a class="cart-contents" href="http://localhost:8888/devo-wordpress/cart">
            <div id=basket>
                <span class="tot-price"><?php echo WC()->cart->get_cart_total(); ?></span>
                <span class="glyphicons glyphicons-shopping-cart"></span>
            </div>
        </a>    }
    <?php
    endif; ?>

Try to understand the if statement you can use if statement like this

if(CONDITION){

}

or like this

if ($value):

endif;

Use 1st case if you are using php only And 2nd if you want to insert html content in between it

Your code contain

<?php if ( $cart_contents_count > 0 ) { ?>

as start and

<?php endif; ?>

and this for end which wrong. Use like this

    <?php if ( $cart_contents_count > 0 ) : ?>
        <a class="cart-contents" href="http://localhost:8888/devo-wordpress/cart">
            <div id=basket>
                <span class="tot-price"><?php echo WC()->cart->get_cart_total(); ?></span>
                <span class="glyphicons glyphicons-shopping-cart"></span>
            </div>
        </a>
    <?php endif; ?>