Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <?php
  2. add_filter( 'woocommerce_checkout_fields', function ( $fields ) {
  3. $offset = 2; //Change this by the field position you want to add (remembering it starts from zero)
  4. $custom_field_id = 'billing_wcj_checkout_field_1'; //Your custom field id
  5. $oldArray = $fields['billing'];
  6. $custom_field = array( $custom_field_id => $oldArray[ $custom_field_id ] );
  7. $newArray = array_slice( $oldArray, 0, $offset, true ) + $custom_field + array_slice( $oldArray, $offset, null, true );
  8. $fields['billing'] = $newArray;
  9. return $fields;
  10. }, PHP_INT_MAX );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement