Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter( 'woocommerce_checkout_fields', function ( $fields ) {
- $offset = 2; //Change this by the field position you want to add (remembering it starts from zero)
- $custom_field_id = 'billing_wcj_checkout_field_1'; //Your custom field id
- $oldArray = $fields['billing'];
- $custom_field = array( $custom_field_id => $oldArray[ $custom_field_id ] );
- $newArray = array_slice( $oldArray, 0, $offset, true ) + $custom_field + array_slice( $oldArray, $offset, null, true );
- $fields['billing'] = $newArray;
- return $fields;
- }, PHP_INT_MAX );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement