0

This should be simple but for whatever reason it is not working for me.

Here is my PHP:

<?php
if (sizeof( $woocommerce->cart->cart_contents ) !== 0) {
    echo '<p>hello there</p>';
}
?>

Basically I want the header to display some custom HTML I have created after an item is added to the cart. This code isn't working correctly though.

Can anyone show me where I am going wrong?

1 Answer 1

0

Try this; it's from the WC function that displays a link to the cart when there are items in the cart. The differences are the use of global and the > 0 operand:

global $woocommerce;
if ( sizeof( $woocommerce->cart->cart_contents) > 0 ) :
    echo '<p>hello there</p>';
endif;
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.