woocommerce/plugins/woocommerce-blocks/assets/js/base/context/hooks/payment-methods/use-payment-methods.js

23 lines
670 B
JavaScript
Raw Normal View History

/**
* Internal dependencies
*/
import { usePaymentMethodDataContext } from '../../providers/cart-checkout/payment-methods';
const usePaymentMethodState = ( express = false ) => {
const {
paymentMethods,
expressPaymentMethods,
paymentMethodsInitialized,
expressPaymentMethodsInitialized,
} = usePaymentMethodDataContext();
return express
? {
paymentMethods: expressPaymentMethods,
isInitialized: expressPaymentMethodsInitialized,
}
: { paymentMethods, isInitialized: paymentMethodsInitialized };
};
export const usePaymentMethods = () => usePaymentMethodState();
export const useExpressPaymentMethods = () => usePaymentMethodState( true );