Last active
June 22, 2017 18:28
-
-
Save gearmobile/cebd3af63f66d0ed2b2b00d8f2e388c2 to your computer and use it in GitHub Desktop.
getters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getDiscountSum (state, getters) { | |
let total = getters.getResult // connect getters getResult | |
for (let i = 0; i < state.discount.length; i += 1) { | |
if (state.discount[i].name === state.discountStatus) { | |
const discount = total * state.discount[i].value / 100 | |
return discount | |
} | |
} | |
}, | |
getPromoSum (state, getters) { | |
let total = getters.getResult // connect getter getResult | |
if (state.promocode.status) { | |
const promo = total - total * state.promocode.percent / 100 | |
return promo | |
} | |
}, | |
getResult (state) { | |
let total = state.order.reduce((sum, c) => sum + c.quantity * c.price, 0) | |
return total | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment