I am looking for a way to implement a cart system into my website which could have multiple products in it with the ability to increment quantities as usual. I know that there are a few plugins that will do this for me but the ones I have found are like 3 years out of date with 200 issues attached to them on GitHub and I would much rather use something that's more up to date or get pointed in the right direction regarding how I would create my own. So if anyone knows any good plugins or has implemented there own cart and wouldn't mind leading me towards how I could do it myself for the cart system.
@vapordev Try not to overcomplicate things. You would have a cart model, and a model for each line item in the cart, which belong to some sort of product model. Each line item has a quantity. So, based on the product’s price and quantity you can derive the line item total, and you can then sum each line items’ total to get the cart total.
You don’t say how you intend to use this with Cashier, though. Either way, you can then pass your cart’s line items to a checkout session to capture the payment via Stripe.
@vapordev I wouldn’t use the session because the session is flushed between logging in/out. So if a guest adds item to their cart, then logs in, the cart will be emptied after logging in.
In the past I’ve stored carts and items in the database and then the identifier in an encrypted cookie.