diff --git a/assets/js/base/context/checkout-context.js b/assets/js/base/context/checkout-context.js index b6c060e543c..5f176115240 100644 --- a/assets/js/base/context/checkout-context.js +++ b/assets/js/base/context/checkout-context.js @@ -7,6 +7,7 @@ import { useState, useMemo, } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; const CheckoutContext = createContext( {} ); @@ -14,7 +15,11 @@ export const useCheckoutContext = () => { return useContext( CheckoutContext ); }; -const CheckoutProvider = ( { children, initialActivePaymentMethod } ) => { +const CheckoutProvider = ( { + children, + initialActivePaymentMethod, + placeOrderLabel = __( 'Place Order', 'woo-gutenberg-product-block' ), +} ) => { const [ successRedirectUrl, setSuccessRedirectUrl ] = useState( '' ); const [ failureRedirectUrl, setFailureRedirectUrl ] = useState( '' ); const [ checkoutComplete, setCheckoutComplete ] = useState( false ); @@ -40,6 +45,7 @@ const CheckoutProvider = ( { children, initialActivePaymentMethod } ) => { updateNotices, activePaymentMethod, setActivePaymentMethod, + placeOrderLabel, }; }, [ successRedirectUrl, @@ -47,6 +53,7 @@ const CheckoutProvider = ( { children, initialActivePaymentMethod } ) => { checkoutComplete, checkoutHasError, activePaymentMethod, + placeOrderLabel, notices, ] ); return ( diff --git a/assets/js/base/hooks/checkout/use-checkout-place-order-label.js b/assets/js/base/hooks/checkout/use-checkout-place-order-label.js new file mode 100644 index 00000000000..f0e1b30630c --- /dev/null +++ b/assets/js/base/hooks/checkout/use-checkout-place-order-label.js @@ -0,0 +1,9 @@ +/** + * External dependencies + */ +import useCheckoutContext from '@woocommerce/base-context/checkout-context'; + +export const useCheckoutPlaceOrderLabel = () => { + const { placeOrderLabel } = useCheckoutContext(); + return placeOrderLabel; +};