Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(coupons.length) {
- let wrWithDiscount = coupons.map(c => {
- let discount
- if(c.discount_percentage) {
- discount = (wr.price - (wr.price * c.discount_percentage / 100))
- }
- if(c.discount_price) {
- discount = (wr.price - c.discount_price)
- }
- return {
- coupon_id: c.id,
- discount: discount
- }
- })
- let smallest = wrWithDiscount.reduce((a, b) => (a.discount > b.discount) ? a : b)
- wr.price = smallest.discount.toFixed(2)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement