• Resolved nanny7

    (@nanny7)


    Hi I haven’t updated to 8.6 because it looks like there are errors from reading posts.
    I have an issue though when on the cart page and hit the cross to empty there is no message. Now I am using a custom function to add more to it than just a message, so how can I get it to work on the cart page please. It works when there are no products in the cart, just not when there is:

    remove_action( 'woocommerce_cart_is_empty', 'wc_empty_cart_message', 10);
     
    add_action( 'woocommerce_cart_is_empty', 'custom_add_content_empty_cart' );
      
    function custom_add_content_empty_cart() {
    	 if ( !is_wc_endpoint_url( 'order-received' ) && WC()->cart->get_cart_contents_count() == 0 ) {
    	echo '<div class="custom-empty">';
       echo '<span class="empty-cart-icon"></span>';
    	echo '<h2>Your Cart Is Currently Empty!</h2>';
    	echo '<p>Looks like you have not made your choice yet.</p>';
    	echo '<a class="button wc-backward" href="' . esc_url( home_url( '/' ) ) . '">Go Shopping</a>';
    	echo '</div>';
    	}	
    }
    • This topic was modified 1 year, 1 month ago by nanny7.
Viewing 1 replies (of 1 total)
  • Hi @nanny7,

    If I understand you correctly, you are having trouble with no cart notifications displaying when you empty your cart, even before adding the custom function. Is that correct?

    As a first step, I’d like to understand how your site is set up, as it could be possible a plugin/theme could be causing the issue. Please share your system status report, which you can find via WooCommerce > Status > Get system report > Copy for support.

    WC()->cart->get_cart_contents_count() == 0

    It also appears you’re having an issue with the custom function not working when there are items in the cart. Is is possible the condition WC()->cart->get_cart_contents_count() == 0 checks if the cart is empty and only then it displays the message.

    I suggested you use WC()->cart->get_cart_contents_count() >= 0 instead, which will check if the cart is empty or has items, and then execute the function.

    If you are still having issues with the function, I suggest reaching out to a developer, as this is out of our support scope.

    Cheers!

Viewing 1 replies (of 1 total)
  • The topic ‘Empty cart no message help’ is closed to new replies.