Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

57
Vistas
Aplying discount in cascade - VueJS

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:

Applying discount for each discount on the product

<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>
7 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos