Jump to content

PS8 shopping cart products count


FerrA

Recommended Posts

Good evening guys, anyone tekll me how can I show the number of products in the cart and not they quantity?

For example, if I add Apple iPod 10x quantity into cart, the number shown in the cart will be 10, but I want shown 1 and not 10.

 

 

There is the code of file ps_shoppingcart.tpl of ps_shoppingcart module

<div id="_desktop_cart">
  <div class="blockcart cart-preview leo-blockcart show-leo-loading  {if $cart.products_count > 0}active{else}inactive{/if}" 
 data-refresh-url="{$refresh_url}" >
    <div class="header">
      {if $cart.products_count > 0}
        <a rel="nofollow" aria-label="{l s='Shopping cart link containing %nbProducts% product(s)' sprintf=['%nbProducts%' => $cart.products_count] d='Shop.Theme.Checkout'}" href="{$cart_url}">
      {/if}
        <span class="left">
           <i class="icomoon icon-cart shopping-cart"></i>
        </span> 
        <span class="right">
          <span class="cart-text">{l s='Cart' d='Shop.Theme.Global'}</span>
          <span class="cart-count">
            <span class="cart-products-count">{$cart.products_count}</span>
            <span class="totals-cart">{$cart.totals.total.value}</span> 
          </span>
            
        </span>
      {if $cart.products_count > 0}
        </a>
      {/if}
    </div>
  </div>
</div>
    

 

Edited by FerrA (see edit history)
Link to comment
Share on other sites

  • 1 month later...
On 6/15/2023 at 9:34 PM, FerrA said:

Good evening guys, anyone tekll me how can I show the number of products in the cart and not they quantity?

For example, if I add Apple iPod 10x quantity into cart, the number shown in the cart will be 10, but I want shown 1 and not 10.

 

 

There is the code of file ps_shoppingcart.tpl of ps_shoppingcart module

<div id="_desktop_cart">
  <div class="blockcart cart-preview leo-blockcart show-leo-loading  {if $cart.products_count > 0}active{else}inactive{/if}" 
 data-refresh-url="{$refresh_url}" >
    <div class="header">
      {if $cart.products_count > 0}
        <a rel="nofollow" aria-label="{l s='Shopping cart link containing %nbProducts% product(s)' sprintf=['%nbProducts%' => $cart.products_count] d='Shop.Theme.Checkout'}" href="{$cart_url}">
      {/if}
        <span class="left">
           <i class="icomoon icon-cart shopping-cart"></i>
        </span> 
        <span class="right">
          <span class="cart-text">{l s='Cart' d='Shop.Theme.Global'}</span>
          <span class="cart-count">
            <span class="cart-products-count">{$cart.products_count}</span>
            <span class="totals-cart">{$cart.totals.total.value}</span> 
          </span>
            
        </span>
      {if $cart.products_count > 0}
        </a>
      {/if}
    </div>
  </div>
</div>
    

 

Replace {$cart.products_count} with {$cart.products|@count} to get the count of unique products in the cart.

 

<span class="cart-products-count">{$cart.products|@count}</span>

Thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...