forked from ahabuda/Custom-Checkout-for-Blocksy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove-order-notes-field.php
More file actions
35 lines (28 loc) · 1.25 KB
/
move-order-notes-field.php
File metadata and controls
35 lines (28 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/**
* Move customer order notes field above the checkboxes.
* Co-author: LoicTheAztec (https://stackoverflow.com/users/3730754/loictheaztec).
*/
// Checkout fields customizations
add_filter( 'woocommerce_checkout_fields' , 'customizing_checkout_fields', 10, 1 );
function customizing_checkout_fields( $fields ) {
// Remove the Order Notes
unset($fields['order']['order_comments']);
// Define custom Order Notes field data array
$customer_note = array(
'type' => 'textarea',
'class' => array('form-row-wide', 'notes'),
'label' => __('Order notes', 'woocommerce'),
//'placeholder' => _x('Notes about you order, e.g. special notes for delivery.', 'placeholder', 'woocommerce'),
'priority' => 111
);
// Set custom Order Notes field
$fields['billing']['billing_customer_note'] = $customer_note;
return $fields;
}
// Set the custom field 'billing_customer_note' in the order object as a default order note (before it's saved)
add_action( 'woocommerce_checkout_create_order', 'customizing_checkout_create_order', 10, 2 );
function customizing_checkout_create_order( $order, $data ) {
$order->set_customer_note( isset( $data['billing_customer_note'] ) ? $data['billing_customer_note'] : '' );
}
?>