test live product - Humma

Detalhes do Produto

tecnologia
(0 avaliações)

test live product

Kz 50 000

router.post("/add", sellerAuth(true), upload.array("images", 5), async (req, res) => { try { const seller = req.user; console.log("🛒 Creating product for seller:", { sellerId: seller._id, sellerName: `${seller.firstName} ${seller.lastName}`, sellerEmail: seller.email }); // Capturar campos do formulário const { title, description, category, subcategory, price, stock, size, color, ml, numero, promoprice, promoPercentage, promo } = req.body; // 🧩 Corrigir tipo do campo promo (evita CastError) let promoFlag = false; if ( promo === "on" || promo === "true" || (promoprice && parseFloat(promoprice) > 0) || (promoPercentage && parseInt(promoPercentage) > 0) ) { promoFlag = true; } // Validação de campos obrigatórios if (!title || !description || !category || !price || !subcategory || !req.files.length || !stock) { return res.redirect("/seller/products/add?error=" + encodeURIComponent("Preencha todos os campos obrigatórios")); } // Validação da categoria const categoryRegex = /^[a-zA-Z0-9\s]*$/; if (!categoryRegex.test(category)) { return res.redirect("/seller/products/add?error=" + encodeURIComponent("Categoria inválida. Use apenas letras, números e espaços.")); } const images = req.files.map(f => f.path); // Processar valores de promoção const promoPriceValue = promoprice ? parseFloat(promoprice) : 0; const promoPercentageValue = promoPercentage ? parseInt(promoPercentage) : 0; // Criar novo produto const novoProduto = new Product({ title: title.trim(), description: description.trim(), category: category.trim().toLowerCase(), subcategory: subcategory.trim(), price: parseFloat(price), images, sellerId: seller._id, isFromSeller: true, StockAvailible: parseInt(stock) || 0, // Campos opcionais size: size ? size.trim() : undefined, color: color ? color.trim().toLowerCase() : undefined, ml: ml ? ml.trim() : undefined, numero: numero ? numero.trim() : undefined, // Campos de promoção promo: promoFlag, promoprice: promoPriceValue, promoPercentage: promoPercentageValue, // Valores padrão rating: 0, totalReviews: 0, soldCount: 0, status: "active", dateOfCreation: new Date() }); await novoProduto.save(); console.log("✅ PRODUCT CREATED SUCCESSFULLY:"); console.log({ id: novoProduto._id, title: novoProduto.title, category: novoProduto.category, subcategory: novoProduto.subcategory, price: novoProduto.price, stock: novoProduto.StockAvailible, promo: novoProduto.promo, promoPrice: novoProduto.promoprice, }); // ✅ Adicionar produto à loja do vendedor try { let store = await Store.findOne({ owner: seller._id }); if (!store) { store = new Store({ name: `${seller.firstName} ${seller.lastName}'s Store`, description: `Loja de ${seller.firstName} ${seller.lastName}`, owner: seller._id, products: [novoProduto._id], }); console.log("🏪 New store created for seller"); } else { store.products.push(novoProduto._id); console.log("📦 Product added to existing store"); } await store.save(); console.log("✅ PRODUCT ADDED TO STORE SUCCESSFULLY"); } catch (storeError) { console.error("⚠️ Error adding product to store:", storeError); } res.redirect("/seller/products/management?success=" + encodeURIComponent("Produto adicionado com sucesso!")); } catch (err) { console.error("❌ Erro ao adicionar produto:", err); res.redirect("/seller/products/add?error=" + encodeURIComponent("Erro ao adicionar produto: " + err.message)); } });

Disponível
Entrega grátis em encomendas acima de Kz 150.000
Pagamento por Multicaixa Express / Referencia
Garantia do produto incluída
Suporte ao cliente 24/7

Descrição do Produto

router.post("/add", sellerAuth(true), upload.array("images", 5), async (req, res) => { try { const seller = req.user; console.log("🛒 Creating product for seller:", { sellerId: seller._id, sellerName: `${seller.firstName} ${seller.lastName}`, sellerEmail: seller.email }); // Capturar campos do formulário const { title, description, category, subcategory, price, stock, size, color, ml, numero, promoprice, promoPercentage, promo } = req.body; // 🧩 Corrigir tipo do campo promo (evita CastError) let promoFlag = false; if ( promo === "on" || promo === "true" || (promoprice && parseFloat(promoprice) > 0) || (promoPercentage && parseInt(promoPercentage) > 0) ) { promoFlag = true; } // Validação de campos obrigatórios if (!title || !description || !category || !price || !subcategory || !req.files.length || !stock) { return res.redirect("/seller/products/add?error=" + encodeURIComponent("Preencha todos os campos obrigatórios")); } // Validação da categoria const categoryRegex = /^[a-zA-Z0-9\s]*$/; if (!categoryRegex.test(category)) { return res.redirect("/seller/products/add?error=" + encodeURIComponent("Categoria inválida. Use apenas letras, números e espaços.")); } const images = req.files.map(f => f.path); // Processar valores de promoção const promoPriceValue = promoprice ? parseFloat(promoprice) : 0; const promoPercentageValue = promoPercentage ? parseInt(promoPercentage) : 0; // Criar novo produto const novoProduto = new Product({ title: title.trim(), description: description.trim(), category: category.trim().toLowerCase(), subcategory: subcategory.trim(), price: parseFloat(price), images, sellerId: seller._id, isFromSeller: true, StockAvailible: parseInt(stock) || 0, // Campos opcionais size: size ? size.trim() : undefined, color: color ? color.trim().toLowerCase() : undefined, ml: ml ? ml.trim() : undefined, numero: numero ? numero.trim() : undefined, // Campos de promoção promo: promoFlag, promoprice: promoPriceValue, promoPercentage: promoPercentageValue, // Valores padrão rating: 0, totalReviews: 0, soldCount: 0, status: "active", dateOfCreation: new Date() }); await novoProduto.save(); console.log("✅ PRODUCT CREATED SUCCESSFULLY:"); console.log({ id: novoProduto._id, title: novoProduto.title, category: novoProduto.category, subcategory: novoProduto.subcategory, price: novoProduto.price, stock: novoProduto.StockAvailible, promo: novoProduto.promo, promoPrice: novoProduto.promoprice, }); // ✅ Adicionar produto à loja do vendedor try { let store = await Store.findOne({ owner: seller._id }); if (!store) { store = new Store({ name: `${seller.firstName} ${seller.lastName}'s Store`, description: `Loja de ${seller.firstName} ${seller.lastName}`, owner: seller._id, products: [novoProduto._id], }); console.log("🏪 New store created for seller"); } else { store.products.push(novoProduto._id); console.log("📦 Product added to existing store"); } await store.save(); console.log("✅ PRODUCT ADDED TO STORE SUCCESSFULLY"); } catch (storeError) { console.error("⚠️ Error adding product to store:", storeError); } res.redirect("/seller/products/management?success=" + encodeURIComponent("Produto adicionado com sucesso!")); } catch (err) { console.error("❌ Erro ao adicionar produto:", err); res.redirect("/seller/products/add?error=" + encodeURIComponent("Erro ao adicionar produto: " + err.message)); } });

Sobre a Humma

Produto oficial da Humma, garantindo qualidade, confiança e a melhor experiência de compra. Todos os nossos produtos passam por rigorosos controlos de qualidade.

Produto Oficial Garantia Humma

Características Principais

Qualidade Garantida

Produto de alta qualidade com garantia de satisfação

Entrega Rápida

Entrega em todo o país com rastreamento

Compra Segura

Transações seguras e protegidas

Suporte Dedicado

Equipa de suporte disponível para ajudar

Informações Adicionais

  • Categoria: tecnologia
  • Subcategoria: homem
  • Stock: Disponível (14 unidades)
  • Vendidos: 6 unidades
  • Adicionado em: 20/10/2025

Informações do Produto

Categoria tecnologia
Subcategoria homem

Disponibilidade & Vendas

Stock Disponível 14 unidades
Total Vendido 6 unidades
Status Ativo
Data de Criação 20/10/2025