I cant figure out how to reorder the additional fields, on the checkout page in WooCommerce.
I have added one extra field to the WooCommerce additional information section. I would like to show the time field first then the order notes below it.
This is the code that I am using:
add_filter( 'woocommerce-additional-fields', 'custom_order_fields', 20, 1 );
function custom_order_fields( $fields ) {
$fields['order_comments']['priority'] = 80;
$fields['woocommerce-delivery-time-field']['priority'] = 70;
return $fields;
}
However, this does not have the desired result. Can someone tell me what I’m doing wrong?
2
Answers
If you want to show your custom field first, and then the order notes.
You can either use:
OR use the
woocommerce_before_order_notes
action hookYou would need to add the field to the WooCommerce Custom Field first before you set the priority likeso.
You can check here for more information on ordering of fields in Woocommerce.