Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

Commit eac84cc

Browse files
committed
fix: check if product is in stock
1 parent 47e2b00 commit eac84cc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/state-indicators.service.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ class StateIndicatorsService {
7575

7676
const getStockAmount = function (stock, product) {
7777
var amount = 0
78-
if (stock[product].amount && typeof stock[product].amount === 'number') {
79-
amount = stock[product].amount
80-
} else if (typeof stock[product] === 'number' || !isNaN(parseInt(stock[product], 10))) {
81-
amount = stock[product]
78+
if (stock[product]) {
79+
if (stock[product].amount && typeof stock[product].amount === 'number') {
80+
amount = stock[product].amount
81+
} else if (typeof stock[product] === 'number' || !isNaN(parseInt(stock[product], 10))) {
82+
amount = stock[product]
83+
}
8284
}
8385
return amount
8486
}

0 commit comments

Comments
 (0)