From ca5168e20f9819a363279fcf9fd5cc8ea7c7c47c Mon Sep 17 00:00:00 2001
From: trongtri35 <57559768+trongtri35@users.noreply.github.com>
Date: Fri, 23 Apr 2021 23:18:56 +0700
Subject: [PATCH] dont show number 0 when cart empty
fix errors when cart items = 0 dont show number 0
---
woocommerce/show-total-cart.md | 38 ++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/woocommerce/show-total-cart.md b/woocommerce/show-total-cart.md
index 94c1cfa..04faa99 100644
--- a/woocommerce/show-total-cart.md
+++ b/woocommerce/show-total-cart.md
@@ -6,25 +6,37 @@ Example:
1. Add → Code Block
2. Insert into `PHP & HTML`:
```HTML
-
- cart->get_cart_contents_count();?>
-
+ cart->get_cart_contents_count() > 0 ) {
+ $display = 'style="display: none;"';
+ }
+?>
+
+ %d ','%d
',WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?>
+
+
```
3. Install [Code Snippets](https://wordpress.org/plugins/code-snippets/)
4. Snippets → Add New
5. Insert into `Code`:
```PHP
- add_filter('woocommerce_add_to_cart_fragments', function($fragments) {
- ob_start();
- ?>
-
-
- cart->get_cart_contents_count(); ?>
-
+ add_filter('woocommerce_add_to_cart_fragments', function($fragments) {
+ob_start();
+ $display = '';
- cart->get_cart_contents_count() > 0 ) {
+ $display = 'style="display: none;"';
+ }
+?>
+
+ %d ','%d
',WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?>
+
+