Open notchahm opened 9 years ago
I'm not sure where to handle the shipping/billing info -- these are needed to complete the order, but are they the responsibility of the shopping cart, or some other entity? Seems like the natural progression is: plz.encart.product('hammer') plz.encart.product('nails') plz.decart.product('hammer') if (customer != null) { plz.create.order(customer, cart) } else { customer = plz.create.customer(name, shipping_address, billing_address, card_info); plz.create.order(customer, cart) } plz.charge.order()
Yeah, maybe there can be a MerchantCustomer module. The flow makes sense though. In the case of e-commerce projects it seems like we might have some overlap in the AdminUser stuff and MerchantCustomer. Same with the client-side component too. I'll have to think that out a bit more.
There is a stripe customer module that takes care of most of this, and one of the nice things about using it is that lessens our security burden since the sensitive data can all be kept on Stripe's servers. I haven't dug to far into the details on Stripe's integration, but it looks like there's a simple way for them to be responsible for all the customer book-keeping and handle customer account management, and there's also a way to do more custom things
as for the cart manipulation methods, what style do you prefer? plz.encart.product() -- follows plz + verb category + actor pattern or plz.add.product.toCart() -- follows more natural language, intuitive request, but is less minimal or something else?
I initially went down the route of plz.add.product( {to: cart} ...) inside of the cart module, and not managing the actual cart container, but then after some deliberation, I've created a separate cart module and added the methods plz.add.cartItem() and plz.remove.cartItem(), which add products to a "cart" collection with the specified customerId. I was considering having a plz.edit.cartItem(), but the only value that makes sense to edit is the quantity field, and that can already be changed through the add and remove methods.
My main concerns with handling the cart internally in the CMS database were: A) tying the cart to a customer (i.e. having one persistent cart per customer), since we don't have customer account management yet, and It would also be nice to allow "anonymous" transactions for customers who don't want to create an account; and B) concerns that the cart could grow indefinitely due to persistent items never being cleaned up. I plan to implement some sort of cart item expiration mechanism in the future
Next step: implement plz.get.cart() method to access/list cart contents and plz.remove.cart() to clear/remove all cart entries for a customer, then something like plz.calculate.subtotal() en route to actually being able to charge stuff
Needs ability to add items to shopping cart (from valid items in products collection) Remove items from cart Specify/edit quantity of items in cart Calculate totals, subtotals Handle shipping/delivery info?