Web Analytics Made Easy -
StatCounter How can I store multiple product_id in the cart table - CodingForum


No announcement yet.

How can I store multiple product_id in the cart table

  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I store multiple product_id in the cart table

    How can I store multiple product_id in the cart table
    ASP.Net Software Development

  • #2
    This is how I would handle things. First you need a table with the customers information. This should link to an order invoice, which will be created when the customers submits his/her order. When the form is sent via a submit button, the items are entered EACH ON IT'S OWN LINE in an items table. each item links to the ORDER INVOICE. This Invoices links to the customer.

    You can find all invoices linked to a customer - and if they are outstanding, paid, in collection, or delivery status just by looking for the customer_Id in the invoice table. And all items in the invoice by looking for the invoice_Id in the items table.
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.


    • #3
      Whilst nearly impossible to ACTUALLY answer given we have no idea what your "cart table" is, how it is structured, how you are accessing it, etc, etc, etc...

      Generally if you would have more than one of an item, that's why you'd have a quantity column so if they add more than one, you don't have a separate record for each one.

      Another approach is to not use the product_id as a unique field, and have a separate ID for each entry in the cart, just as you would for each user in same. If you INSIST on each instance of a product in the cart being unique:

      customer_id INT NOT NULL
      product_id INT NOT NULL
      Would be the way to do it. You should have that anyways since it's not like you're making a separate table for each and every blasted user, right?

      But really I'd also have:

      quantity INT
      In there as well so I'm not making more records than I need to. It's often also more useful for the user to be able to just change "how many" than add/remove each and every blasted one.

      Something you question implies is part of the mechanism, but again guessing wildly since you basically gave us nothing to go on.

      I'll kill you and your dreams tonight, begin new life.
      Bleed your death upon me, let your bloodline feed my youth.