Skip to content

Instantly share code, notes, and snippets.

@helpercode0
Last active December 22, 2024 17:13
Show Gist options
  • Save helpercode0/c32915b37d14bf723c6c6191adb832f1 to your computer and use it in GitHub Desktop.
Save helpercode0/c32915b37d14bf723c6c6191adb832f1 to your computer and use it in GitHub Desktop.
Add Field in Checkout Woocommerce Block Programmatically
add_action(
'woocommerce_init',
function() {
woocommerce_register_additional_checkout_field(
array(
'id' => 'namespace/delivery-date-id',
'label' => 'Delivery Date',
'optionalLabel' => 'Delivery Date (optional)',
'location' => 'address',
'required' => true,
'attributes' => array(
'autocomplete' => 'delivery-date-id',
'aria-describedby' => 'some-element',
'aria-label' => 'custom aria label',
'title' => 'Title to show on hover',
'data-custom' => 'custom data',
),
),
);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment