Skip to content

Commit 8c1c5d9

Browse files
committed
chore: return product id in shopping cart example (#1918)
1 parent c0bad80 commit 8c1c5d9

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

examples/classic/shopping-cart/components/ShoppingCart.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<div class="cart">
33
<h2>Your Cart</h2>
4-
<p v-show="!products.length"><i>Please add some products to cart.</i></p>
4+
<p v-show="!products.length">
5+
<i>Please add some products to cart.</i>
6+
</p>
57
<ul>
6-
<li
7-
v-for="product in products"
8-
:key="product.id">
8+
<li v-for="product in products" :key="product.id">
99
{{ product.title }} - {{ currency(product.price) }} x {{ product.quantity }}
1010
</li>
1111
</ul>

examples/classic/shopping-cart/store/modules/cart.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const getters = {
1414
return state.items.map(({ id, quantity }) => {
1515
const product = rootState.products.all.find(product => product.id === id)
1616
return {
17+
id: product.id,
1718
title: product.title,
1819
price: product.price,
1920
quantity

examples/composition/shopping-cart/components/ShoppingCart.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<template>
22
<div class="cart">
33
<h2>Your Cart</h2>
4-
<p v-show="!products.length"><i>Please add some products to cart.</i></p>
4+
<p v-show="!products.length">
5+
<i>Please add some products to cart.</i>
6+
</p>
57
<ul>
6-
<li
7-
v-for="product in products"
8-
:key="product.id">
8+
<li v-for="product in products" :key="product.id">
99
{{ product.title }} - {{ currency(product.price) }} x {{ product.quantity }}
1010
</li>
1111
</ul>

examples/composition/shopping-cart/store/modules/cart.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const getters = {
1313
return state.items.map(({ id, quantity }) => {
1414
const product = rootState.products.all.find(product => product.id === id)
1515
return {
16+
id: product.id,
1617
title: product.title,
1718
price: product.price,
1819
quantity

0 commit comments

Comments
 (0)