Skip to content

Instantly share code, notes, and snippets.

@xadapter
Created August 11, 2016 07:19
Show Gist options
  • Select an option

  • Save xadapter/f4cfc0d98e94c1170feb2ec65ae2ebeb to your computer and use it in GitHub Desktop.

Select an option

Save xadapter/f4cfc0d98e94c1170feb2ec65ae2ebeb to your computer and use it in GitHub Desktop.
WooCommerce - Add a new Custom Checkout Field
add_action( 'woocommerce_after_order_notes', 'xa_new_custom_checkout_field' );
function xa_new_custom_checkout_field( $checkout ) {
echo '<div id="xa_new_custom_checkout_field"><h2>' . __('SSN') . '</h2>';
woocommerce_form_field( 'new_field_ssn', array(
'type' => 'text',
'class' => array('ssn-field-class form-row-wide'),
'label' => __('SSN Number'),
'placeholder' => __('Enter SSN'),
), $checkout->get_value( 'new_field_ssn' ));
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment