1

Im customizing the checkout of Magento and having some issue in html templates. I copy the cart-items.html from the magento-checkout module in my theme but, when i change the template structure the js stop running and no one error in the console.

<div class="block items-in-cart" data-bind="mageInit: {'collapsible':{'openedState': 'active', 'active': isItemsBlockExpanded()}}">
<div class="title" data-role="title">
    <strong role="heading" aria-level="1">
        <translate args="maxCartItemsToDisplay" if="maxCartItemsToDisplay < getCartLineItemsCount()"/>
        <translate args="'of'" if="maxCartItemsToDisplay < getCartLineItemsCount()"/>
        <span data-bind="text: getCartSummaryItemsCount()"></span>
        <translate args="'Item in Cart'" if="getCartLineItemsCount() === 1"/>
        <translate args="'Items in Cart'" if="getCartLineItemsCount() > 1"/>
    </strong>
</div>

Im my template i changed for this

<div class="block items-in-cart">
<div class="title" data-role="title">
        <span data-bind="text: getCartSummaryItemsCount()"></span> Item (s)
</div>
but the

data-bind="text: getCartSummaryItemsCount()" not working. Can someone explain to me please?

1 Answer 1

0

Your code works but your html structure caused the Items Count (wrapped by the span tag and doesn't has the strong tag as the parent) hidden by Magento default CSS.

The best way is wrapping the span tag by a strong tag (same as magento default) or you have to add custom CSS to display your span tag.

The Item (s) text should be translated, so your code should be:

<div class="block items-in-cart">
    <div class="title" data-role="title">
        <strong role="heading" aria-level="1">
            <span data-bind="text: getCartSummaryItemsCount()"></span>
            <translate args="'Item (s)'"></translate>
        </strong>
    </div>

You can remove role, aria-level attributes from strong tag if you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.