Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created February 18, 2012 16:27
Show Gist options
  • Save mikejolley/1860056 to your computer and use it in GitHub Desktop.
Save mikejolley/1860056 to your computer and use it in GitHub Desktop.
WooCommerce - Override billing fields
add_filter( 'woocommerce_billing_fields', 'custom_woocommerce_billing_fields' );
function custom_woocommerce_billing_fields( $fields ) {
// Over-ride a single label
$fields['billing_first_name']['label'] = 'Your label';
// Over-ride a single required value
$fields['billing_first_name']['required'] = false;
// Over-ride the entire thing
$fields['billing_postcode'] = array(
'label' => __('Postcode', 'woothemes'),
'placeholder' => __('Postcode', 'woothemes'),
'required' => true,
'class' => array('form-row-last update_totals_on_change')
);
/**
* You can over-ride - billing_first_name, billing_last_name, billing_company, billing_address_1, billing_address_2, billing_city, billing_postcode, billing_country, billing_state, billing_email, billing_phone
*/
return $fields;
}
@tobiasschutter
Copy link

The filter is triggered in WC_Countries::get_address_fields().

@manuman94
Copy link

Thank you guy, saved my day ;)

@alidemirci
Copy link

Thank You So Much

@aimejayd
Copy link

Any one who can help please am not able to remove some fields that i don't want like address, country etc can you help me?

@vijayvp710
Copy link

That was an issue regarding class. It's not working.
Can you please help me for class. because I need to add custom class.

'class' => array('form-row-last update_totals_on_change')
This line add but not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment