2020-04-01 09:27:53 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { ShippingDataProvider } from '../shipping';
|
|
|
|
import { CheckoutStateProvider } from '../checkout-state';
|
2020-04-29 10:57:58 +00:00
|
|
|
import { PaymentMethodDataProvider } from '../payment-methods';
|
2020-04-01 09:27:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cart provider
|
|
|
|
* This wraps the Cart and provides an api interface for the Cart to
|
|
|
|
* children via various hooks.
|
|
|
|
*
|
2020-04-30 09:52:36 +00:00
|
|
|
* @param {Object} props Incoming props for the provider.
|
|
|
|
* @param {Object} [props.children] The children being wrapped.
|
|
|
|
* @param {string} [props.redirectUrl] Initialize what the cart will
|
|
|
|
* redirect to after successful
|
|
|
|
* submit.
|
2020-04-01 09:27:53 +00:00
|
|
|
*/
|
2020-04-30 09:52:36 +00:00
|
|
|
export const CartProvider = ( { children, redirectUrl } ) => {
|
2020-04-01 09:27:53 +00:00
|
|
|
return (
|
2020-04-30 09:52:36 +00:00
|
|
|
<CheckoutStateProvider redirectUrl={ redirectUrl } isCart={ true }>
|
2020-04-29 10:57:58 +00:00
|
|
|
<ShippingDataProvider>
|
|
|
|
<PaymentMethodDataProvider>
|
|
|
|
{ children }
|
|
|
|
</PaymentMethodDataProvider>
|
|
|
|
</ShippingDataProvider>
|
2020-04-01 09:27:53 +00:00
|
|
|
</CheckoutStateProvider>
|
|
|
|
);
|
|
|
|
};
|