use-shopping-cart icon indicating copy to clipboard operation
use-shopping-cart copied to clipboard

Supporting "Custom" configuration for <CartProvider />

Open dayhaysoos opened this issue 3 years ago • 2 comments

Overview

Not all countries are able to use Stripe, however, users would like to take advantage of the shopping cart state and logic that USC provides. Right now, there are Stripe values that are required in the current set up.

Goal

It would be ideal to pass a "custom" prop to the CartProvider that makes it so that no config is required at all.

Approach

As of right now, there is a ClientOnly config and a CustomCheckout config. They each share a "Common Config" which is where the Stripe values are required:

https://github.com/dayhaysoos/use-shopping-cart/blob/c08f1a9db00b26f637aa386bea7eff191ee84fe0/use-shopping-cart/core/index.d.ts#L50

We would need a "CustomConfig" that requires only one prop: currency

It's needed for adding items to the cart and creating total values for display. I don't think it would be a good idea to leave currency out of it.

Possibilities

Perhaps users may want to take advantage of using props that DO get passed to the CartProvider. Was wondering if it would be a good idea to make a useCustomProps hook to do this.

Providing Feedback

Feel free to comment here with any issues/concerns!

dayhaysoos avatar Jan 17 '22 17:01 dayhaysoos

Given we are removing stripe most people will need a way to do some form of gathering customer info and maybe using a different payment gateway. Besides currency we should add a prop called checkoutUrl.

Let´s add the useCustomProps hook once we have a basic CartProvider working without stripe.

LarsBuur avatar Jan 17 '22 18:01 LarsBuur

Sounds good! Do you want me to assign this to you btw?

dayhaysoos avatar Jan 17 '22 18:01 dayhaysoos