diff --git a/plugins/woocommerce-blocks/assets/js/blocks/checkout/edit.tsx b/plugins/woocommerce-blocks/assets/js/blocks/checkout/edit.tsx index 4d99784b057..8d24a110c08 100644 --- a/plugins/woocommerce-blocks/assets/js/blocks/checkout/edit.tsx +++ b/plugins/woocommerce-blocks/assets/js/blocks/checkout/edit.tsx @@ -86,9 +86,11 @@ export const Edit = ( { } ); // Hack to get it update in editor wcSettings.defaultFields.phone.hidden = ! showField; - wcSettings.defaultFields.phone.required = showField; + if ( showField ) { + wcSettings.defaultFields.phone.required = true; + } }; - + console.log( { requirePhoneField, showPhoneField } ); const setRequirePhoneFieldEntity = ( value: string ) => { dispatch( coreStore ).editEntityRecord( 'root', 'site', undefined, { woocommerce_checkout_phone_field: @@ -245,10 +247,8 @@ export const Edit = ( { value={ { showApartmentField, showCompanyField, - showPhoneField, requireApartmentField, requireCompanyField, - requirePhoneField, showOrderNotes, showPolicyLinks, showReturnToCart, diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/Checkout.php b/plugins/woocommerce/src/Blocks/BlockTypes/Checkout.php index 2215306e752..9c3cfbc6b3a 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/Checkout.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/Checkout.php @@ -33,7 +33,7 @@ class Checkout extends AbstractBlock { protected function initialize() { parent::initialize(); add_action( 'wp_loaded', array( $this, 'register_patterns' ) ); - add_action( 'init', array( $this, 'register_settings' ) ); + add_action( 'wp_loaded', array( $this, 'register_settings' ) ); // This prevents the page redirecting when the cart is empty. This is so the editor still loads the page preview. add_filter( 'woocommerce_checkout_redirect_empty_cart',