• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

98
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>
almost 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda