Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    Error when adding a product in cart

    General Discussion
    2
    2
    137
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      LilD last edited by

      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;
      
      1 Reply Last reply Reply Quote 0
      • devansh-webkul
        devansh-webkul last edited by

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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post