Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › How to hide the mini cart in the header if the cart is empty
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › How to hide the mini cart in the header if the cart is empty
- This topic has 13 replies, 3 voices, and was last updated 9 years by Rui Guerreiro – SUPPORT.
-
Posted in: Neighborhood
-
March 18, 2015 at 3:25 pm #158723
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,
StijnMarch 18, 2015 at 10:29 pm #158825Hi,
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
March 19, 2015 at 10:35 am #158960Hi 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,
StijnMarch 19, 2015 at 11:18 am #158992There 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
March 19, 2015 at 4:18 pm #159125OK, 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
March 19, 2015 at 5:17 pm #159149Just 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
March 19, 2015 at 5:22 pm #159151can you provide me ftp code to check the code change that I recommended earlier?
-RuiMarch 19, 2015 at 7:31 pm #159181if ($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!
March 20, 2015 at 8:51 am #159292Great, thanks 🙂
March 20, 2015 at 10:21 am #159327it is still not working for me, could you check if the code is correct? and provide me with a solution?
Best,
StijnMarch 20, 2015 at 10:27 am #159332Sorry I misread. Rui is asking for the FTP details
– Kyle
March 20, 2015 at 12:28 pm #159382This reply has been marked as private.March 21, 2015 at 12:05 pm #159528Hi Rui and Kyle,
Could you check my code via the ftp access that I gave you?
Thank you a lot!
March 24, 2015 at 10:53 am #160188Hi,
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
-
Posted in: Neighborhood
You must be logged in and have valid license to reply to this topic.