• Resolved ladislavsulc

    (@ladislavsulc)


    Hi! The plugin looks sweet! I would like the ability to hide the cart unless there is a product added. Is it possible to do this? If so, how?

    Thank you!

Viewing 7 replies - 1 through 7 (of 7 total)
  • I’m also wondering if this is possible

    • This reply was modified 4 years, 11 months ago by quit160.
    Plugin Author xootix

    (@xootix)

    Hi @quit160

    Its a paid feature.
    Here is the snippet to make it work with the free version, please add this code to your functions.php

    add_action( 'wp_footer', function(){
    	if( WC()->cart->is_empty() ):
    	?>
    		<style type="text/css">
    			.xoo-wsc-basket{
    				display: none;
    			}
    		</style>
    	<?php
    	endif; ?>
    } );
    Thread Starter ladislavsulc

    (@ladislavsulc)

    @xootix thank you!

    Thread Starter ladislavsulc

    (@ladislavsulc)

    There were some errors so this is what works for me:

    // Woo Sidecart - hide when empty
    add_action( 'wp_footer', function() {
        
        if ( WC()->cart->is_empty() ) {
            
            echo '<style type="text/css">.xoo-wsc-basket{ display: none; }</style>';
        
        }
    
    });

    The slight usability problem is when you add something to the cart, close the side cart, the basket icon only appears after a refresh or navigating to another page.

    • This reply was modified 4 years, 11 months ago by ladislavsulc.

    Thanks for sharing @xootix!

    Your code does show a small error like @ladislavsulc mentions. Is there anyway to fix that code?

    @xootix, thank you for your service! I am also trying to hide the basket when empty. It would be great to have this basic option in the free version.

    • This reply was modified 4 years, 10 months ago by RockSea.

    I can’t find the functions.php file in the plugin directory, or do I need to add it to the general functions.php?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Hide cart when empty’ is closed to new replies.