Skip to content

Commit

Permalink
Merge pull request #2483 from pauluse/feature/add-items-minicart-coun…
Browse files Browse the repository at this point in the history
…t-type

Feature/add items minicart count type
  • Loading branch information
pkarw committed Feb 22, 2019
2 parents 392604e + 1308f7c commit 2626f9e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improve images loading on category page, corrected alt view and blinking problem - @patzick (#2465)
- Improve tsconfig for better IDE paths support - @patzick, @filrak (#2474)
- fix breadcrumbs changing too early - @filrak (#2469)
- add cart count config, allows you to display the item count instead of a sum of the item quantities - @pauluse (#2483)
- improved product gallery load view, shows correct image on reload - @patzick (#2481, #2382)

### Deprecated / Removed
Expand Down
1 change: 1 addition & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
"setConfigurableProductOptions": true,
"askBeforeRemoveProduct": true,
"displayItemDiscounts": true,
"minicartCountType": "quantities",
"create_endpoint": "http://localhost:8080/api/cart/create?token={{token}}",
"updateitem_endpoint": "http://localhost:8080/api/cart/update?token={{token}}&cartId={{cartId}}",
"deleteitem_endpoint": "http://localhost:8080/api/cart/delete?token={{token}}&cartId={{cartId}}",
Expand Down
6 changes: 5 additions & 1 deletion core/modules/cart/store/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ const getters: GetterTree<CartState, RootState> = {
return totalsArray
}
},
totalQuantity (state) {
totalQuantity (state, getters, rootStore) {
if (rootStore.config.cart.minicartCountType === 'items') {
return state.cartItems.length
}

return sumBy(state.cartItems, (p) => {
return p.qty
})
Expand Down
6 changes: 6 additions & 0 deletions docs/guide/basics/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ If this option is set to `true`, in case of configurable products, Vue Storefron

If this option is set to `true`, Vue Storefront will add use price item with a discount to the shopping cart. Otherwise, the product price and special will be added to the shopping cart instead.

```json
"minicartCountType": "quantities",
```

If this option is set to `items`, Vue Storefront will calculate the cart count based on items instead of the item quantities.

```json
"create_endpoint": "http://localhost:8080/api/cart/create?token={{token}}",
"updateitem_endpoint": "http://localhost:8080/api/cart/update?token={{token}}&cartId={{cartId}}",
Expand Down

0 comments on commit 2626f9e

Please sign in to comment.