change save logic

This commit is contained in:
Nadir Seghir 2024-09-19 16:27:46 +02:00
parent ec004dbdcd
commit 21037bb406
2 changed files with 5 additions and 5 deletions

View File

@ -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,

View File

@ -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',