Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

iamDiscovery's avatar

Looking for Cart system using Cashier Stripe

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.

0 likes
5 replies
martinbean's avatar

@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.

1 like
iamDiscovery's avatar

Ah okay, well that makes sense. How would you temporarily store the cart information for a user tho? Session data? Or create a table for it in DB?

martinbean's avatar

@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.

2 likes
iamDiscovery's avatar

Okay, that all makes sense, thanks by the way. Do you know where I can find out how to create encrypted cookies and stuff inside of the database?

martinbean's avatar
Level 80

@vapordev Laravel encrypts cookies by default. And you can just create Eloquent models for your carts and their line items.

1 like

Please or to participate in this conversation.