How to reorder checkout form fields in WooCommerce

add_filter("woocommerce_checkout_fields", "order_fields");

function order_fields($fields) {
    $order = array(
        "billing_first_name", 
        "billing_last_name",                
        "billing_phone",
		"billing_email",         
        "billing_postcode", 
    );
    foreach($order as $field)
    {
        $ordered_fields[$field] = $fields["billing"][$field];
    }
    $fields["billing"] = $ordered_fields;
    return $fields;

}

How to remove order notes from checkout form fields in WooCommerce

add_filter('woocommerce_enable_order_notes_field', '__return_false');

Change label and placeholder of checkout form fields in WooCommerce


add_filter( 'woocommerce_checkout_fields' , 'override_checkout_fields_placeholder' );

function override_checkout_fields_placeholder( $fields ) {
     $fields['order']['order_comments']['placeholder'] = 'Custom placeholder';
     $fields['order']['order_comments']['label'] = 'Custom  label';
     return $fields;
}

Remove field from checkout form fields in WooCommerce

add_filter( 'woocommerce_checkout_fields' , 'remove_checkout_fields' );


function remove_checkout_fields( $fields ) {
     unset($fields['order']['order_comments']);
     return $fields;
}

Add address field from checkout form fields in WooCommerce

add_filter( 'woocommerce_default_address_fields' , 'add_address_fields' );

     function add_address_fields( $address_fields ){
    
     $temp_fields = array();

     $address['title'] = array(
    'label'     => __('Title', 'woocommerce'),
    'required'  => true,
    'class'     => array('form-row-wide'),
    'type'  => 'select',
    'options'   => array('Mr' => __('Mr', 'woocommerce'), 'Mrs' => __('Mrs', 'woocommerce'))
     );
	 
	 $address['address_1'] = array(
    'label' => __('Area', 'woocommerce'),
    'placeholder'=> '',
    'class'     => array('form-row-wide', 'address-field'),
    'type'  => 'text'
     );
	  return $address;
	 }

Leave comment

Your email address will not be published. Required fields are marked with *.