Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

62
Vistas
ProductVariants incrementToCart and decreaseToCart problem ..Add to cart work perfectly but incrementToCart button not work...so please help me

This my cart code it it work good with ProductVariants id perfectly work....but incrementToCart not work

 {
        export const addToCart = (product) => (dispatch, getState) => {
          const cartItems = getState().cart.cartItems.slice();
        
          if (!product.selectedVariant) {
            product.selectedVariant = product.ProductVariants[0];
          }
          const existingProductIndex = cartItems.findIndex(p => p.id === product.id && p.selectedVariant.id === product.selectedVariant.id);
          if (existingProductIndex > -1) {
            cartItems[existingProductIndex].selectedVariant.qty += product.selectedVariant.qty;
            NotificationManager.success("Successfully updated", "", 1500);
          } else {
            cartItems.push({ ...product });
            NotificationManager.success("Successfully added", "", 1500);
          }
          dispatch({
            type: ADD_TO_CART,
            payload: { cartItems },
          });
        
          sessionStorage.setItem("cartItems", JSON.stringify(cartItems));
        };
    
    console.log - this data.....
    id: 9, productId: 4, actualPrice: null, distributorPrice: 480, marginPer: 58
    }

This is my incrementTocar code...here may be problem but I can't find so please help me....

export const incrementToCart = (product) => (dispatch, getState) => {
                  const cartItems = getState().cart.cartItems.slice()
                  const selectProduct = cartItems.find(item => item.id === product.productId)
                
                  const index = cartItems.indexOf(selectProduct)
                  const value = cartItems[index].ProductVariants[0];
                
                  console.log(value)
                  value.qty = value.qty + 1;
                  value.total = value.qty * value.netPrice;
                
                  dispatch({
                    type: INCREASE_QUANTITY,
                    payload: { cartItems },
                  });
                  NotificationManager.success("Successfully qnty updated", "", 1500);
                  sessionStorage.setItem("cartItems", JSON.stringify(cartItems));
                }
    
    
    
about 4 years ago · Santiago Gelvez
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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda