Magento 2 Show Count 0 On Mini Cart When No Product Is In Cart

In this post, I will guide you on Magento 2 Show Count 0 On Mini Cart When No Product Is In Cart. Notify customers that they have no products in their shopping cart.

This is considered an effective business campaign without spending a lot of money. When your mini cart shows zero, it means there are no products in the cart, this will motivate customers to add items to the cart.

Steps To Show Count 0 On Mini Cart When No Product Is In Cart

Changing the core file is not an optimal solution so we will overwrite the core file with the theme. If you are using any theme please replace it with your theme.

1. Connect to your server via SSH and go to the Magento document root.

2. Override minicart.phtml.

Copy from:

vendor/magento/module-checkout/view/frontend/templates/cart/minicart.phtml

Paste to:

app/design/frontend/<Vendor-name>/<Theme-name>/Magento_Checkout/te‌​mplates/cart/minicar‌​t.phtml

3. Replace the below code:

Find:

<span class="counter-number"><!-- ko text: getCartParam('summary_count') --><!-- /ko --></span>

Replace to:

<!-- ko if: getCartParam(summary_count') -->
  
<span class="counter-number"><!-- ko text: cart().summary_count --><!-- /ko --></span>
  
<!-- /ko -->
  
<!-- ko ifnot: getCartParam('summary_count') -->
  
<span class="counter-number">0</span>
  
<!-- /ko -->

4. Override CSS file

Copy from:

vendor/magento/theme-frontend-luma/Magento_Checkout/web/css/source/module/_minicart.less

Paste to:

app/design/frontend/<Vendor-name>/<Theme-name>/Magento_Checkout/web/css/source/module/_minicart.less

5. Make changes in CSS file

Find:

&.empty {
  
display: none;
  
}

Replace to:

&.empty {
  
display: inline-block;
  
}

Once done, check the results:

Show Count 0 On Mini Cart

This is the end of the Magento 2 Show Count 0 On Mini Cart When No Product Is In Cart.

Follow us for the more helpful posts!

We hope this is a useful post for you How To Upload Product Image Placeholder In Magento 2.

Thank you for reading!

3 2 votes
Article Rating

Aaron LX

Aaron is a passionate writer, crazy about shopping, eCommerce and trends. Besides his outstanding research skills and a positive mind, Aaron eagerly shares his experience with the readers.

Leave a Reply or put your Question here

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x