diff --git a/assets/js/base/components/cart-checkout/place-order-button/index.tsx b/assets/js/base/components/cart-checkout/place-order-button/index.tsx index d4f3cc7fecd..68c4da0a19e 100644 --- a/assets/js/base/components/cart-checkout/place-order-button/index.tsx +++ b/assets/js/base/components/cart-checkout/place-order-button/index.tsx @@ -4,6 +4,8 @@ import { useCheckoutSubmit } from '@woocommerce/base-context/hooks'; import { Icon, check } from '@wordpress/icons'; import Button from '@woocommerce/base-components/button'; +import { STORE_NOTICES_STORE_KEY } from '@woocommerce/block-data'; +import { useSelect } from '@wordpress/data'; const PlaceOrderButton = (): JSX.Element => { const { @@ -15,6 +17,21 @@ const PlaceOrderButton = (): JSX.Element => { waitingForRedirect, } = useCheckoutSubmit(); + const hasNoticesVisible = useSelect( ( select ) => { + const noticeContainers = select( + STORE_NOTICES_STORE_KEY + ).getContainers(); + const noticeStore = select( 'core/notices' ); + return noticeContainers.some( ( container ) => { + return ( + noticeStore + .getNotices( container ) + .filter( ( notice ) => notice.status === 'error' ).length > + 0 + ); + } ); + } ); + return (