New Landing How can we help? Themeforest Theme Support Neighborhood How to hide the mini cart in the header if the cart is empty

Viewing 14 posts - 1 through 14 (of 14 total)
  • #158723
    stijnue149
    Member
    Post count: 23

    Hi Swiftideas,

    I would like to know how I can hide the empty cart in the header. I don’t want to show the 0,00 but just remove it. CSS is not working, but i cannot find a way in the php files to change this, but i think it must be easy to do. Just change/remove the if cart is empty function in php.

    Could you provide me this? It is not in the woocommerce templates but in the swiftframework as far as i can see.

    Thank you a lot.

    Best,
    Stijn

    #158825
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    Find the code below inside the file neighborhood\includes\swift-framework\sf-content-display\sf-header.php

    
    if ($show_cart_count) {
    					$cart_output .= '<li class="parent shopping-bag-item"><a class="cart-contents" href="'.$woocommerce->cart->get_cart_url().'" title="'.__("View your shopping bag", "swiftframework").'"><i class="sf-cart"></i>'.$cart_total.' ('.$cart_count.')</a>';
    				} 
    

    and replace by

    
    if ($show_cart_count) {
       if ( $cart_count > 0){
    	$cart_output .= '<li class="parent shopping-bag-item"><a class="cart-contents" href="'.$woocommerce->cart->get_cart_url().'" title="'.__("View your shopping bag", "swiftframework").'"><i class="sf-cart"></i>'.$cart_total.' ('.$cart_count.')</a>';
       }else{
    	$cart_output .= '<li class="parent shopping-bag-item"><a class="cart-contents" href="'.$woocommerce->cart->get_cart_url().'" title="'.__("View your shopping bag", "swiftframework").'"><i class="sf-cart"></i></a>';
       
       }
    } 
    

    Let us know if it worked.

    -Rui

    #158960
    stijnue149
    Member
    Post count: 23

    Hi Rui,

    Thank you for the code, unfortunately it is not working I still see the empty basket with the price 0,00.

    I am not sure (no programm skills here), but why is there still a cart output defined, if cart_count is 0?

    Thank you for your help, hope you can come up with a solution!!

    Best,
    Stijn

    #158992
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    There is an option to disable the cart count in the Header Options .
    The option is “Cart aux item count”

    Well the cart output it’s to maintain the logic, if we show it when it has products we also show that is zero when it’s empty. It always depends on the interpretation.

    -Rui

    #159125
    stijnue149
    Member
    Post count: 23

    OK, I have seen that option, but in my opinion there is no value for a customer to know that the basket is empty (it is attracting wrong attention). Therefore i want to remove it only when it is empty.

    do you have another solution in php? as hiding with css is not possible.

    Thank you a lot.

    Stijn

    #159149
    stijnue149
    Member
    Post count: 23

    Just to add:

    I have found out that the cart in the header is not showing if you are on the cart page. So there is somewhere a line of code that exclude the minicart on the cart page. Isn’t it possible to extend this exclusion easily?

    Thanks

    #159151
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    can you provide me ftp code to check the code change that I recommended earlier?
    -Rui

    #159181
    stijnue149
    Member
    Post count: 23
    if ($show_cart_count) {
       if ( $cart_count < 0){
        $cart_output .= '<li class="parent shopping-bag-item"><a class="cart-contents" href="'.$woocommerce->cart->get_cart_url().'" title="'.__("View your shopping bag", "swiftframework").'"><i class="sf-cart"></i>'.$cart_total.' ('.$cart_count.')</a>';
       }
    }  else {
    					$cart_output .= '<li class="parent shopping-bag-item"><a class="cart-contents" href="'.$woocommerce->cart->get_cart_url().'" title="'.__("View your shopping bag", "swiftframework").'"><i class="sf-cart"></i>'.$cart_total.'</a>';
    
    				}

    Thank you!

    #159292
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Great, thanks 🙂

    #159327
    stijnue149
    Member
    Post count: 23

    it is still not working for me, could you check if the code is correct? and provide me with a solution?

    Best,
    Stijn

    #159332
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Sorry I misread. Rui is asking for the FTP details

    – Kyle

    #159382
    stijnue149
    Member
    Post count: 23
    This reply has been marked as private.
    #159528
    stijnue149
    Member
    Post count: 23

    Hi Rui and Kyle,

    Could you check my code via the ftp access that I gave you?

    Thank you a lot!

    #160188
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    I don’t see my suggest changes inside the code of sf-header.php
    Can you provide the url of your site(forgot to ask) so I can check the changes I will made?

    Thanks

    -Rui

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register