Skip to content

Instantly share code, notes, and snippets.

@SiR-DanieL
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiR-DanieL/3659c323e25d50d135c7 to your computer and use it in GitHub Desktop.
Save SiR-DanieL/3659c323e25d50d135c7 to your computer and use it in GitHub Desktop.
Add checkout VAT and SSN fields
// Add VAT and SSN fields to the checkout form
add_filter( 'woocommerce_checkout_fields' , 'custom_add_vat_ssn_fields' );
function custom_add_vat_ssn_fields( $fields ) {
if ( ! isset( $fields['billing']['billing_vat'] ) ) {
$fields['billing']['billing_vat'] = array(
'label' => __( 'VAT', 'your-domain' ),
'placeholder' => _x( 'VAT', 'placeholder', 'your-domain' ),
'required' => true, //change to false if you do not need this field to be required
'class' => array( 'form-row-first' )
);
}
if ( ! isset( $fields['billing']['billing_ssn'] ) ) {
$fields['billing']['billing_ssn'] = array(
'label' => __( 'SSN', 'your-domain' ),
'placeholder' => _x( 'SSN', 'placeholder', 'your-domain' ),
'required' => true, //change to false if you do not need this field to be required
'class' => array( 'form-row-last' )
);
}
return $fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment