Recent Topics

Error when adding a product in cart



  • Hi, I've changed the grouped products a bit so that I want only the product grouped with its data and price in my cart.
    The product is added to the cart but the price is always 0 and from my debut it appears instead that the price is 0 when the cart takes over the items but when I send this item it has a price
    Look how I did it

    $productFlat = ProductFlat::where('product_id', $data['product_id'])->first();
    
            $productTest = Product::findOrFail($productFlat->product_id);
    
            $products = [
                [
                    'product_id'        => $productFlat->product_id,
                    'sku'               => $productFlat->sku,
                    'quantity'          => $data['quantity'],
                    'name'              => $productFlat->name,
                    'price'             => $productFlat->price * $data['quantity'],
                    'base_price'        => $productFlat->price * $data['quantity'],
                    'total'             => $productFlat->price * $data['quantity'],
                    'base_total'        => $productFlat->price * $data['quantity'] * $data['quantity'],
                    'weight'            => $productFlat->weight ?? 0,
                    'total_weight'      => ($productFlat->weight ?? 0) * $data['quantity'],
                    'base_total_weight' => ($productFlat->weight ?? 0) * $data['quantity'],
                    'type'              => $productFlat->type,
                    'additional'        => $this->getAdditionalOptions($data),
                ],
            ];
    
            return $products;
    


  • Grouped product price calculation is based on the number of child products's minimum amount.


Log in to reply