I added the following to the functions.php It displays the checkout page fine and all of the typical fields but it does not add the new field or even a little text. I’m using the unaltered storefront theme and no special plugins.
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my_custom_checkout_field"><h3>'.__('My Field').'</h3>';
woocommerce_form_field( 'my_field_name', array(
'type' => 'text',
'class' => array('my-field-class orm-row-wide'),
'label' => __('Fill in this field'),
'placeholder' => __('Enter a number'),
), $checkout->get_value( 'my_field_name' ));
echo '</div>';
}
Any ideas as to why this field is not showing? Everything I’ve seen indicates it should work. I’ve also confirmed the function is loaded.
2
Answers
you are probably using the blocks checkout, delete it and replace it with the shortcode one.
it worked for me.
Edit the checkout page to remove the default WooCommerce block and include the shortcode
[woocommerce_checkout]
in the editor.