Skip to content

Instantly share code, notes, and snippets.

@sibaberpollo
Last active June 29, 2018 11:19
Show Gist options
  • Save sibaberpollo/e1b713a55e2d63a5bdf7a2a092b3de19 to your computer and use it in GitHub Desktop.
Save sibaberpollo/e1b713a55e2d63a5bdf7a2a092b3de19 to your computer and use it in GitHub Desktop.
En el function.php
<?php
add_filter( "woocommerce_checkout_fields", "reordering_checkout_fields", 15, 1 );
function reordering_checkout_fields( $fields ) {
## ---- 1. REORDERING BILLING FIELDS ---- ##
// Set the order of the fields
$billing_order = array(
'billing_rut',
'billing_first_name',
'billing_last_name',
'billing_email',
'billing_phone',
'billing_company',
'billing_country',
'billing_address_1',
'billing_address_2',
'billing_postcode',
'billing_state',
'billing_city'
);
$count = 0;
$priority = 10;
// Updating the 'priority' argument
foreach($billing_order as $field_name){
$count++;
$fields['billing'][$field_name]['priority'] = $count * $priority;
}
## ---- 2. CHANGING SOME CLASSES FOR BILLING FIELDS ---- ##
$fields['billing']['billing_rut']['class'] = array('form-row-wide');
$fields['billing']['billing_email']['class'] = array('form-row-first');
$fields['billing']['billing_phone']['class'] = array('form-row-last');
$fields['billing']['billing_state']['class'] = array('form-row-first');
$fields['billing']['billing_city']['class'] = array('form-row-last');
## ---- RETURN THE BILLING FIELDS CUSTOMIZED ---- ##
return $fields;
}
@sibaberpollo
Copy link
Author

sibaberpollo commented Jun 29, 2018

Y en en tmp-somela/woocommerce/checkout/form-billing.php

<script> $ = jQuery; $( window ).load(function() { $("#billing_address_1_field").insertAfter("#billing_postcode_field"); $("#billing_address_2_field").insertAfter("#billing_address_1_field"); }); </script>

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