Hey Folks,
imagine you have a “shopping cart” full of items. Each item has a unique “SellerID”.
Now I would like to create an order in the database PER sellerID.
That means I would have to split the shopping cart, basically an array full of items, into individual arrays, split by the respective sellerID.
Sure I can iterate over the sellerIDs and could, "if sellerID == item.sellerID populate some other array, but that’s where I’m stuck right now.
With the number of individual sellerIDs within the cart, I could declare arrays before iterating on each, but that doesn’t seem pragmatic to me.
I’m also more about the principle and whether there is a pragmatic solution to this problem.
PS have personally already decided that I rewrite the shopping cart, so that there is already ordered from the beginning by seller ID, then I can create the order directly iterate over the individual seller IDs of the cart.
Still, I’m interested if there is a solution-oriented way if I haven’t already sorted it by SellerID in the cart before.
So thanks in advance for thinking about it!