Magento2: Mini Cart: Display Cart Summary - "Display item quantities" count not working as expected

Created on 7 Apr 2018  路  9Comments  路  Source: magento/magento2


Preconditions


  1. Magento 2.2.3
  2. Magento Luma theme with Sample Data

Steps to reproduce

  1. Set Sales -> Checkout -> My Cart Link -> Display item quantities
  2. Add 1 item to the cart with qty of 1
  3. Add a second item to the cart of qty 2

Expected result

  1. Cart Count in Header should state 3
  2. Cart Count within Minicart should state 3

Actual result

  1. Cart Count within Minicart states 2


After review of logic, the count within the mini cart always performs "Display number of items in cart" regardless of Admin setting. As a note: this is for the count within the Mini cart.

I reproduced this issue on stock Magento 2.2.3 with Sample data, however, I forgot to take a screenshot. Below is a screenshot of a recent project displaying the same issue.

display item quantities

Checkout Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.2.x Reproduced on 2.3.x

Most helpful comment

Please ask questions before "closing" if you do not understand.

All 9 comments

Hello @duffner, thank you for your report.
We've acknowledged the issue and added to our backlog.

Closing as not a bug. The settings Set Sales -> Checkout -> My Cart Link relates only to the number of items shown in the box near LOGIN link, i.e. the link which opens the cart

@slavvka, what you're saying is correct, however that's the bug. The feature is not consistent as there are two locations for item cart count in the "mini cart" once in the header display, the other within the minicart itself.

Please ask questions before "closing" if you do not understand.

@slavvka If it's not a bug, please answer the following question . "How can you have 5 items and 2 items in the cart at the same time?" This makes absolutely no sense.

@duffner thanks for catching that. In Luma theme we have "items" label hidden with CSS so didn't see the inconsistency.
The correct behavior would be:

  1. Replace the field label Sales -> Checkout -> My Cart Link -> Display Cart Summary to Cart Counter Shows
    wewewe
  2. Update the labels inside the dropdown to be:
    Number of products in cart
    Total number of items in cart
    screen shot 2018-12-13 at 2 30 40 pm
  3. Add logic that changes label in mini cart link:
    if "Number of products in cart" selected the label is "products"
    if "Total number of items in cart" selected the Lebel is "items"
    screen shot 2018-12-13 at 3 02 55 pm
  4. Replace "items" inside the mini cart with "products" as the setting above doesn't influence this counting.
    ws

@tkacheva, thanks for providing the additional information! I test off of base, not Luma, I guess I need to specify this in future tickets. Once again, thank you

Solution to problem described:

  • Copy file vendor/magento/module-checkout/view/frontend/web/template/minicart/content.html to your template
  • Change <span class="count" text="getCartLineItemsCount()"/> to <span class="count" text="getCartParam('summary_count')"/>

@Volvoxpl I tried your recommendation, It says unable to process binding. getCartParam is not defined

Any thoughts?

UPDATE

I was editing cart-items.html for checkout page, not minicart. But to fellow explorers who might want to show total cart items in checkout area, replace getCartLineItemsCount with getItemsQty
The involved js file is vendor/magento/module-checkout/view/frontend/web/js/view/summary/cart-items.js

here are my notes https://tutes.in/how-to-show-correct-item-count-in-magento-2-checkout-order-summary/

The method mentioned by @Volvoxpl works fine for minicart because it involves js
vendor/magento/module-checkout/view/frontend/web/js/view/minicart.js

Was this page helpful?
0 / 5 - 0 ratings