Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add items minicart count type #2483

Merged
merged 6 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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