Additional checkout block fields – validation
-
Hello, you provide an example of validation can also be against other fields in your documentation:
woocommerce_register_additional_checkout_field(
array(
'id' => 'plugin-namespace/alt-email',
'label' => 'Confirm our email address',
'location' => 'contact',
'type' => 'text',
'required' => true,
'attributes' => array(
'autocomplete' => 'off',
),
'sanitize_callback' => function ( $field_value ) {
return sanitize_email( $field_value );
},
'validation' => array(
"type" => "string",
"format" => "email",
"not" => array(
"const" => array(
"$data", "0/customer/billing_address/email"
)
),
"errorMessage" => "Please ensure your email address matches the confirmation.",
),
)
);Variable
$datashould to refer to the current field value, but it makes an error. Please help.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Additional checkout block fields – validation’ is closed to new replies.