Home › Forums › Basel support forum › Hide "0" in empty cart
Hide "0" in empty cart
- This topic has 4 replies, 2 voices, and was last updated 7 years, 5 months ago by Artem Temos.
-
AuthorPosts
-
June 18, 2017 at 8:08 pm #15316
DenisshishkinParticipantHello,
How can I remove “0” on the cart icon when there’s no item in shopping cart? I would like to show the item numbers only when user adds items to the cart.Thanks.
June 18, 2017 at 8:53 pm #15318
Artem TemosKeymasterHello,
Thank you so much purchasing our theme and contacting our support center.
Try to add the following code snippet to the functions.php file in the child theme
function basel_cart_count() { if( WC()->cart->cart_contents_count == 0) return; ?> <span class="basel-cart-number"><?php echo WC()->cart->cart_contents_count; ?></span> <?php }
Kind Regards
XTemos StudioJune 18, 2017 at 9:01 pm #15319
DenisshishkinParticipantThanks, it works!
Perhaps this code can be applied to the wish list as well?June 18, 2017 at 9:05 pm #15320
DenisshishkinParticipantAnd maybe you can add a different css class for an empty basket and for a basket with a value of 1 or more? Just now the value appears only after the page is updated… It would be cool if the figure appeared immediately after adding to the basket. I would add to the empty display: none, and to the full block
June 19, 2017 at 6:07 am #15322
Artem TemosKeymasterTry this one
function basel_header_block_cart() { $position = basel_get_opt('cart_position'); $design = basel_get_opt('shopping_cart'); $extra_class = 'basel-cart-icon'; if( basel_get_opt('shopping_icon_alt') ) { $extra_class .= ' basel-cart-alt'; } if( $position == 'side' ) { $extra_class .= ' cart-widget-opener'; } if( WC()->cart->cart_contents_count == 0 ){ $extra_class .= "empty-widget"; } if ( basel_woocommerce_installed() && $design != 'disable' ): ?> <div class="shopping-cart basel-cart-design-<?php echo esc_attr( $design ); ?> <?php echo esc_attr( $extra_class ); ?>"> <a href="<?php echo esc_url(WC()->cart->get_cart_url()); ?>"> <span><?php esc_html_e('Cart', 'basel'); ?> (<span>o</span>)</span> <span class="basel-cart-totals"> <?php basel_cart_count(); ?> <span class="subtotal-divider">/</span> <?php basel_cart_subtotal(); ?> </span> </a> <?php if ( $position != 'side'): ?> <div class="dropdown-wrap-cat"> <div class="dropdown-cat"> <?php // Insert cart widget placeholder - code in woocommerce.js will update this on page load echo '<div class="widget woocommerce widget_shopping_cart"><div class="widget_shopping_cart_content"></div></div>'; ?> </div> </div> <?php endif ?> </div> <?php endif; }
And this code will hide wishlist
function basel_header_block_wishlist() { if( YITH_WCWL()->count_products() == 0 ) return; if ( basel_woocommerce_installed() && class_exists( 'YITH_WCWL' ) && basel_get_opt('header_wishlist') ): ?> <div class="wishlist-info-widget"> <a href="<?php echo esc_url(YITH_WCWL()->get_wishlist_url()); ?>"><?php esc_html_e( 'Wishlist', 'basel' ) ?> <span><?php echo YITH_WCWL()->count_products(); ?></span></a> </div> <?php endif; }
Regards
-
AuthorPosts
Tagged: cart
- You must be logged in to create new topics. Login / Register