• Resolved kazikamuntu

    (@kazikamuntu)


    Hi, i added a new custom field in checkout MYCUSTOMFIELD
    but it appears at the end (is the last field).

    I’ve tried with

    add_filter(“woocommerce_checkout_fields”, “order_fields”); function order_fields($fields) { $order = array( “MYCUSTOMFIELD”, “billing_first_name”, “billing_last_name”,”billing_country”,”cf”, “billing_company”, “billing_address_1”, “billing_address_2”, “billing_postcode”, “billing_email”, “billing_phone” ); foreach($order as $field) { $ordered_fields[$field] = $fields[“billing”][$field]; } $fields[“billing”] = $ordered_fields; return $fields; }

    but it appears a blank field and the real field custom is still at the end…

Viewing 5 replies - 1 through 5 (of 5 total)
  • I wouldn’t expect that to work. You’ll need to set the field priorities, for example:

    $fields['billing_first_name']['priority'] = 10;
    $fields['billing_last_name']['priority'] = 20;
    $fields['billing_email']['priority'] = 30;
    Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    Lorro is correct, you’d need priorities.

    You can use the examples above, or you can use a plugin like Checkout field editor: https://www.woocommerce.com/products/woocommerce-checkout-field-editor/

    Thread Starter kazikamuntu

    (@kazikamuntu)

    Thanks,
    if i add custom field with
    function custom_override_checkout_fields( $fields ) etc
    it worked
    but my jquery script doesnt work if i add filter
    ________________________________

    My custom fields are added in a plugin with

        echo '<div id="cf_checkout_field">';
          woocommerce_form_field( 'MYFIELD', 
                                array(
                                    'type'          => 'text',
                                    'class'         => array('MYFIELD-class form-row-wide'),
                                    'label'         => __('CUSTOM FIELD'),
                                    'placeholder'   => __('INSERT CUSTOM FIELD'),
                                    'required'  => true, 
                                    'clear'     => true,
                                    'custom_attributes' => array( 'required' => 'required' ),
                                    ), 
                              $checkout->get_value( 'MYFIELD' ));
        echo '</div>';

    I can’t set priority for this

    Sorry, its not really practical to debug code via the forum.

    fondashci

    (@fondashci)

    Hi Lorro,
    could you post please a full example how to change the priority of one field ?
    lets say the billing first name
    but all the snippet in order to added to the function.php of my child theme ?
    thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘REORDER CHECKOUT FIELDS’ is closed to new replies.