Check cart is NOT empty Woocommerce 3.4+

0

I want to check if the cart is NOT empty, but I can not! Can someone help me, please?

.

add_action( 'wp_footer', 'redirecionar' );
    function redirecionar(){
        global $woocommerce;
        if ( !sizeof($woocommerce->cart->cart_contents) ) {
           // hello_world
        }
}

..

add_action( 'wp_footer', 'vazio' );
    function vazio() {
        if ( ! WC()->cart->get_cart_contents_count() == 0 ) { 
           // hello_world
        }
}

...

add_action( 'wp_footer', 'vazio' );
    function vazio() {
        if ( ! WC()->cart->is_empty() ) { 
           // hello_world
         }
}

My code:

<?php add_action( 'wp_footer', 'vazio' );
    function vazio() {
        if ( ! WC()->cart->is_empty() ) { ?>
        <div style="width: 20%;" class="footer-section <?php echo esc_html($woo);?>">
            <a href="<?php echo 'https://my_web_page.pt/finalizar-compra';?>" title="Finalizar Compra"><i class="fa fa-credit-card"></i></a>
        </div>
    <?php   }
    } ?>
    
asked by anonymous 03.06.2018 / 13:12

0 answers