Viewing 4 replies - 1 through 4 (of 4 total)
  • I am having a similar issue where I change the order of woocommerce_shipping_fields and woocommerce_billing_fields but they are re-ordered back with javascript. If I disable JS on my account page the fields are ordered properly.

    As mikejolley stated here: https://github.com/woocommerce/woocommerce/issues/14618 this should be answered here but I cannot find it. Any help is appreciated!

    Thread Starter webrightnow

    (@webrightnow)

    Any help with this? It seems to me that this is something that should be possible. Or perhaps Woo won’t help because they’d rather sell their Checkout Field Editor plugin? I am not really wanting to spend $49 just to move a single field further up, sorry guys…

    • This reply was modified 7 years, 8 months ago by webrightnow.

    add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ );
    function custom_override_checkout_fields( $fields ) {
    $fields[‘billing’][‘landline_phone’] = array(
    ‘label’ => __(‘Landline phone’, ‘woocommerce’),
    ‘placeholder’ => _x(”, ‘placeholder’, ‘woocommerce’),
    ‘required’ => false,
    ‘clear’ => false,
    ‘type’ => ‘tel’,
    ‘priority’ => ‘105’,
    );
    return $fields;
    }

    // Display under the admin section
    add_action( ‘woocommerce_admin_order_data_after_billing_address’, ‘my_custom_checkout_field_display_admin_order_meta’, 10, 1 );
    function my_custom_checkout_field_display_admin_order_meta($order){
    echo ‘<p>‘.__(‘Landline Phone’).’: ‘ . get_post_meta( $order->id, ‘_landline_phone’, true ) . ‘</p>’;
    }

    //Save fields after checkout
    add_action( ‘woocommerce_checkout_update_order_meta’, ‘my_custom_checkout_field_update_order_meta’ );
    function my_custom_checkout_field_update_order_meta( $order_id ) {
    if ( ! empty( $_POST[‘landline_phone’] ) ) {
    update_post_meta( $order_id, ‘_landline_phone’, sanitize_text_field( $_POST[‘landline_phone’] ) );
    }
    }

    Thread Starter webrightnow

    (@webrightnow)

    Thanks for the solution. In this case I solved the problem using the Woo Checkout Field Editor plugin, which worked brilliantly. I’ll test your solution on the next project.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom billing field order’ is closed to new replies.