I need to show discounts on discounts, so far I have managed to show the main discount on the product, but I need this discount to accumulate in the values.
Please could someone help me to apply these discounts correctly.
Here an example of the discount at the moment:
<template>
<div class="samurai-single-product-dcto">
<p v-for="discount in discounts" :key="discount.id">
<span class="title-promotion">{{discount.titulo}}:</span>
<strong class="price-promotion">
{{discountPrice(singleProduct.selectedProduct.precio,discount.descuentoCupon) | toCurrency }}
</strong>
<strong class="text-iva">{{$store.getters.showIva}}</strong>
</p>
</div>
</template>
<script>
import { mapState } from 'vuex';
import _ from 'lodash';
export default {
name:'SamuraiSingleProductDcto',
computed:{
...mapState({
singleProduct:'singleProduct',
discounts(state){
let result = state.singleProduct.selectedProduct.descuentos.filter(element => (element.tipoCupon && !element.codigoCupon));
return _.uniqBy(result, 'id');
}
})
},
methods:{
discountPrice(price, discount){
let priceResult = this.$store.getters.removeIva(price);
let discountResult = 1 - (discount / 100);
return Math.round( priceResult * discountResult);
}
}
}
</script>