Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
add placeOrderLabel to checkout context and add hook for exposing
Browse files Browse the repository at this point in the history
  • Loading branch information
nerrad committed Dec 20, 2019
1 parent a9c4313 commit ff4d96e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion assets/js/base/context/checkout-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ import {
useState,
useMemo,
} from '@wordpress/element';
import { __ } from '@wordpress/i18n';

const CheckoutContext = createContext( {} );

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 );
Expand All @@ -40,13 +45,15 @@ const CheckoutProvider = ( { children, initialActivePaymentMethod } ) => {
updateNotices,
activePaymentMethod,
setActivePaymentMethod,
placeOrderLabel,
};
}, [
successRedirectUrl,
failureRedirectUrl,
checkoutComplete,
checkoutHasError,
activePaymentMethod,
placeOrderLabel,
notices,
] );
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* External dependencies
*/
import useCheckoutContext from '@woocommerce/base-context/checkout-context';

export const useCheckoutPlaceOrderLabel = () => {
const { placeOrderLabel } = useCheckoutContext();
return placeOrderLabel;
};

0 comments on commit ff4d96e

Please sign in to comment.