2020-08-20 14:14:12 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
2020-09-18 18:39:32 +00:00
|
|
|
import {
|
|
|
|
useEmitResponse,
|
|
|
|
useExpressPaymentMethods,
|
2021-04-08 12:31:12 +00:00
|
|
|
} from '@woocommerce/base-context/hooks';
|
2020-08-20 14:14:12 +00:00
|
|
|
import { StoreNoticesProvider } from '@woocommerce/base-context';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import ExpressPaymentMethods from '../express-payment-methods';
|
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
const CartExpressPayment = () => {
|
|
|
|
const { paymentMethods, isInitialized } = useExpressPaymentMethods();
|
2020-09-18 18:39:32 +00:00
|
|
|
const { noticeContexts } = useEmitResponse();
|
2020-08-20 14:14:12 +00:00
|
|
|
|
|
|
|
if (
|
|
|
|
! isInitialized ||
|
|
|
|
( isInitialized && Object.keys( paymentMethods ).length === 0 )
|
|
|
|
) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="wc-block-components-express-payment wc-block-components-express-payment--cart">
|
|
|
|
<div className="wc-block-components-express-payment__content">
|
2020-09-18 18:39:32 +00:00
|
|
|
<StoreNoticesProvider
|
|
|
|
context={ noticeContexts.EXPRESS_PAYMENTS }
|
|
|
|
>
|
2020-08-20 14:14:12 +00:00
|
|
|
<ExpressPaymentMethods />
|
|
|
|
</StoreNoticesProvider>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="wc-block-components-express-payment-continue-rule wc-block-components-express-payment-continue-rule--cart">
|
|
|
|
{ /* translators: Shown in the Cart block between the express payment methods and the Proceed to Checkout button */ }
|
|
|
|
{ __( 'Or', 'woo-gutenberg-products-block' ) }
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default CartExpressPayment;
|