Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hirejordansmith/ecafc14cb0d17ae9ba96 to your computer and use it in GitHub Desktop.
Save hirejordansmith/ecafc14cb0d17ae9ba96 to your computer and use it in GitHub Desktop.
How to change the WooCommerce checkout page billing and address forms
<?php
// WooCommerce Checkout Fields Hook
add_filter( 'woocommerce_checkout_fields' , 'hjs_wc_checkout_fields' );
// This example changes the default placeholder text for the state drop downs to "Select A State"
function hjs_wc_checkout_fields( $fields ) {
$fields['billing']['billing_state']['placeholder'] = 'Select A State';
$fields['shipping']['shipping_state']['placeholder'] = 'Select A State';
return $fields;
}
<?php
// Billing Field - left side of checkout page
['billing']['billing_first_name']
['billing']['billing_last_name']
['billing']['billing_company']
['billing']['billing_address_1']
['billing']['billing_address_2']
['billing']['billing_city']
['billing']['billing_postcode']
['billing']['billing_country']
['billing']['billing_state']
['billing']['billing_email']
['billing']['billing_phone']
<?php
// These are the specific properties that can be used to customize the checkout fields
['type'] // Field Type. Valid types are text, textarea, password, or select.
['label'] // Field Label. Above the input box.
['placeholder'] // Placeholder text. Inside the input box.
['class'] // add a class to the field
['required'] // Display whether field should be required or not. Values either "true" or "false"
['clear'] // Apply clear fix to the field. Values either "true" or "false"
['label_class'] // add class to field label
['options'] // modify select boxes with an array of values
<?php
// Shipping Field - right side of checkout page
['shipping']['shipping_first_name']
['shipping']['shipping_last_name']
['shipping']['shipping_company']
['shipping']['shipping_address_1']
['shipping']['shipping_address_2']
['shipping']['shipping_city']
['shipping']['shipping_postcode']
['shipping']['shipping_country']
['shipping']['shipping_state']
['account']['account_username']
['account']['account_password']
['account']['account_password-2']
['order']['order_comments']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment