Combine orders with one order invoice number

I’m making an online shopping app, but I’m confused, how do I combine several orders in one order number when the user checkouts.

You have to create an order (cart) number and assign items to it. Then filter items by this order number. I have a sample here: