Skip to content

Instantly share code, notes, and snippets.

@ScottDeLuzio
Created August 14, 2015 23:18
Show Gist options
  • Save ScottDeLuzio/c045066e7f3e09a708ea to your computer and use it in GitHub Desktop.
Save ScottDeLuzio/c045066e7f3e09a708ea to your computer and use it in GitHub Desktop.
Add custom field to checkout page
/**
* Add the field to the checkout page
*/
add_action( 'woocommerce_after_order_notes', 'some_custom_checkout_field' );
function some_custom_checkout_field( $checkout ) {
echo '<div id="some_custom_checkout_field"><h2>' . __('My Field Header') . '</h2>';
woocommerce_form_field( 'some_field_name', array(
'type' => 'text',
'class' => array('my-field-class form-row-wide'),
'label' => __('My Field Label'),
'placeholder' => __('Some placeholder text to guide the customer'),
'required' => true,
), $checkout->get_value( 'some_field_name' ));
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment