TIPOFF / checkout

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

Optional Location #30

Closed drewroberts closed 3 years ago

drewroberts commented 3 years ago

Location is added to both cart and order through location_id as an unsigned Integer that is nullable on cart and order. This allows optional integration of locations on Bookings (https://github.com/tipoff/bookings) and Products (https://github.com/tipoff/products) and other packages. The primary purpose is allowing location-based payment options.

drewroberts commented 3 years ago

Applies to both Cart #34 & Order #32

sl0wik commented 3 years ago

This is the definition of package-crossing we spoke about. In real life, the checkout process cart is not responsible for defining the payment method. Cart is a simple bag for items. Checkout should control what can be done in terms of payments.

drewroberts commented 3 years ago

Yes, but Checkout is in the same package and needs to have the option of location-based billing if that is included in the application. I need to know what carts were created with a location.

pdbreen commented 3 years ago

Can you expand on what you mean by location based payment options? Could this be as extreme as one location using stripe and another using braintree? Or, is this more like everyone uses stripe, but some allow for ACH and some don't?

sl0wik commented 3 years ago

Brainstorm: It looks like it's getting in inventory namespace. The glue that connecting product (T-shirt or Ticket) and business is usually inventory ownership. We mentioned the case where products can be sold cross country and tickets (bookings) are local. In such case t-shirt inventory might be owned by other entity than booking?

drewroberts commented 3 years ago

We'll force all locations to use Stripe. We won't allow Carts or Orders to have Items (bookings or products) from different locations if locations are enabled. If locations are enabled (which they are now in our main repo), then they will force separate checkout transactions if a customer wants to order things from different locations. For now, we are not shipping anything and are not going to worry about inventory, but will allow for that later in the tipoff/products package.

pdbreen commented 3 years ago

Implemented as nullable location_id on cart/order and cartitem/orderitem. When cart items are added to the cart, the item location (if set) is propagated to the cart with checks to ensure there are never multiple locations for items in the same cart.

https://github.com/tipoff/checkout/blob/ac48005bbe014998f2fe2fb365256302d7351b0d/tests/Unit/Models/CartModelInterfaceTest.php#L219

https://github.com/tipoff/checkout/blob/ac48005bbe014998f2fe2fb365256302d7351b0d/tests/Unit/Models/CartModelInterfaceTest.php#L240