diff --git a/plugins/woocommerce-blocks/assets/js/base/components/block-error-boundary/types.ts b/plugins/woocommerce-blocks/assets/js/base/components/block-error-boundary/types.ts index 6f383cceed1..b15f4c50d53 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/block-error-boundary/types.ts +++ b/plugins/woocommerce-blocks/assets/js/base/components/block-error-boundary/types.ts @@ -47,7 +47,7 @@ export interface BlockErrorBoundaryProps extends BlockErrorBase { * Override the default error with a function that takes the error message and returns a React component */ renderError?: ( props: RenderErrorProps ) => React.ReactNode; - showErrorMessage?: boolean; + showErrorMessage?: boolean | undefined; } export interface DerivedStateReturn { diff --git a/plugins/woocommerce-blocks/assets/js/base/components/sidebar-layout/style.scss b/plugins/woocommerce-blocks/assets/js/base/components/sidebar-layout/style.scss index 107915bd2bd..72a3babfa39 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/sidebar-layout/style.scss +++ b/plugins/woocommerce-blocks/assets/js/base/components/sidebar-layout/style.scss @@ -4,6 +4,10 @@ margin: 0 auto $gap; position: relative; + .wc-block-must-login-prompt { + display: block; + } + .wc-block-components-main { box-sizing: border-box; margin: 0; diff --git a/plugins/woocommerce-blocks/assets/js/blocks/checkout/block.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/block.tsx index deebe6ec439..105eb63e141 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/checkout/block.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/block.tsx @@ -35,20 +35,20 @@ import type { Attributes } from './types'; import { CheckoutBlockContext } from './context'; import { hasNoticesOfType } from '../../utils/notices'; -const LoginPrompt = () => { +const MustLoginPrompt = () => { return ( - <> +
{ __( - 'You must be logged in to checkout. ', + 'You must be logged in to checkout.', 'woo-gutenberg-products-block' - ) } + ) }{ ' ' } { __( 'Click here to log in.', 'woo-gutenberg-products-block' ) } - +
); }; @@ -84,22 +84,29 @@ const Checkout = ( { return ; } + /** + * If checkout requires an account (guest checkout is turned off), render + * a notice and prevent access to the checkout, unless we explicitly allow + * account creation during the checkout flow. + */ if ( isLoginRequired( customerId ) && - getSetting( 'checkoutAllowsSignup', false ) + ! getSetting( 'checkoutAllowsSignup', false ) ) { - ; + return ; } return ( { children } diff --git a/plugins/woocommerce-blocks/assets/js/settings/shared/default-constants.ts b/plugins/woocommerce-blocks/assets/js/settings/shared/default-constants.ts index 8e1158f2090..b6b8fff87a7 100644 --- a/plugins/woocommerce-blocks/assets/js/settings/shared/default-constants.ts +++ b/plugins/woocommerce-blocks/assets/js/settings/shared/default-constants.ts @@ -9,7 +9,7 @@ import { allSettings } from './settings-init'; export const ADMIN_URL = allSettings.adminUrl; export const COUNTRIES = allSettings.countries; export const CURRENCY = allSettings.currency; -export const CURRENT_USER_IS_ADMIN = allSettings.currentUserIsAdmin; +export const CURRENT_USER_IS_ADMIN = allSettings.currentUserIsAdmin as boolean; export const HOME_URL = allSettings.homeUrl; export const LOCALE = allSettings.locale; export const ORDER_STATUSES = allSettings.orderStatuses;