WooCommerce Cart Tab Zero Items Fix – Update

If you’re using WooCommerce and have the Cart Tab installed, you may not want it persistently visible. To fix this, adding this line:

if ( sizeof( $woocommerce->cart->cart_contents ) == 0 ) {
// The cart is empty
} else {

above:

if ( ! is_cart() && ! is_checkout() ) {

To close out the argument, add a } to the end of the function. The whole section should look like this:

// Display the cart tab and widget
function woocommerce_cart_tab() {
global $woocommerce;
$skin = get_option( ‘wc_ct_skin’ );
$position = get_option( ‘wc_ct_horizontal_position’ );
$widget = get_option( ‘wc_ct_cart_widget’ );
if ( sizeof( $woocommerce->cart->cart_contents ) == 0 ) {
// The cart is empty
} else {
if ( ! is_cart() && ! is_checkout() ) {
if ( $widget == ‘yes’ ) {
echo ‘<div>’;
} else {
echo ‘<div>’;
}
wcct_cart_button();
// Display the widget if specified
if ( $widget == ‘yes’ ) {
// Check for WooCommerce 2.0 and display the cart widget
if ( version_compare( WOOCOMMERCE_VERSION, “2.0.0” ) >= 0 ) {
the_widget( ‘WC_Widget_Cart’, ‘title=’ );
} else {
the_widget( ‘WooCommerce_Widget_Cart’, ‘title=’ );
}
}
echo ‘</div>’;
}}
}
}

Update – 02 July
James Koster, the developer, has updated the pluggin so it’s a selectable feature. Once you update, go to WooCommerce Settings, click on the Catalog tab and scroll to the bottom… you’ll see the option:

Hide the cart tab if the cart is empty

Advertisements
Posted in WooCommerce

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 149 other followers

%d bloggers like this: