Commit 9abe1a439031090db9bd089a4bde63095e25d9de
1 parent
c8b1956700
Exists in
develop
Fix
Logica para detectar si la personalozacion de sinonimos son identicas para sumar cantidad
Showing
1 changed file
with
12 additions
and
5 deletions
Show diff stats
src/app/services/articulo/articulo.service.ts
| ... | ... | @@ -41,7 +41,6 @@ export class ArticuloService { |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | addCant(articulo: IArticulo) { |
| 44 | - if (articulo.cantidad >= articulo.ExiVta) return; | |
| 45 | 44 | articulo.cantidad++; |
| 46 | 45 | this.calcularTotal(); |
| 47 | 46 | } |
| ... | ... | @@ -56,10 +55,18 @@ export class ArticuloService { |
| 56 | 55 | setArticulo(articulo: IArticulo) { |
| 57 | 56 | articulo.cantidad = 1; |
| 58 | 57 | for (const articuloCarrito of this.carrito) { |
| 59 | - if (articuloCarrito.id === articulo.id && !articulo.productos) { | |
| 60 | - articuloCarrito.cantidad++; | |
| 61 | - this.calcularTotal(); | |
| 62 | - return; | |
| 58 | + if (articuloCarrito.id === articulo.id) { | |
| 59 | + if (!articuloCarrito.productos) break; | |
| 60 | + let samePromo = false | |
| 61 | + articuloCarrito.productos.forEach((a, i) => { | |
| 62 | + samePromo = (a.id === articulo.productos[i].id); | |
| 63 | + }); | |
| 64 | + if (samePromo) { | |
| 65 | + this.addCant(articuloCarrito); | |
| 66 | + return; | |
| 67 | + } else { | |
| 68 | + break; | |
| 69 | + } | |
| 63 | 70 | } |
| 64 | 71 | } |
| 65 | 72 | this.setArticulosSinImagen([articulo]); |