TIPOFF / checkout

Laravel Package for Ecommerce Checkouts
MIT License
0 stars 1 forks source link

Cart Expiration #31

Closed drewroberts closed 3 years ago

drewroberts commented 3 years ago

All Carts will expire. There is an expired_at field that allows users to have multiple old carts and allows Bookings to expire carts. Required and defaults to 3 months from created_at datetime. The Booking package will update and set the expired_at field to 10 minutes from the last time a booking was added as a cart item.

drewroberts commented 3 years ago

The question we are discussing is that in addition to expiring the Cart #34, do we also need to expire Cart Items #35 and if so, how does that impact Abandoned Carts #43 ?

pdbreen commented 3 years ago

Cart items have a required expires_at with a default of 3 months. When a cart item is created from a Sellable, the sellable has the ability to override the default via the CartItemInterface::setExpiresAt(...) method. Expiring an item does not remove it from the cart.

https://github.com/tipoff/checkout/blob/ac48005bbe014998f2fe2fb365256302d7351b0d/src/Models/CartItem.php#L63

Cart expiration is determined dynamically as the min expiration for any item it contains.

https://github.com/tipoff/checkout/blob/ac48005bbe014998f2fe2fb365256302d7351b0d/src/Models/Cart.php#L200

When fetching a users active cart, carts with expired items are excluded. This means that once a cart has expired items, a new, empty cart will be created. This will leave the prior cart and its items in tact for abandon cart targeting.

https://github.com/tipoff/checkout/blob/ac48005bbe014998f2fe2fb365256302d7351b0d/src/Models/Cart.php#L104 https://github.com/tipoff/checkout/blob/ac48005bbe014998f2fe2fb365256302d7351b0d/src/Models/Cart.php#L212