mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
20 lines
688 B
Text
20 lines
688 B
Text
add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
|
|
|
|
add_filter( 'woocommerce_checkout_fields' , 'wc_custom_order_notes' );
|
|
|
|
function wc_custom_order_notes( $fields ) {
|
|
$fields['billing']['new_order_notes'] = array(
|
|
'type' => 'textarea',
|
|
'label' => 'New Order Notes',
|
|
'class' => array('form-row-wide'),
|
|
'clear' => true,
|
|
'priority' => 999,
|
|
);
|
|
return $fields;
|
|
}
|
|
|
|
add_action( 'woocommerce_checkout_create_order', 'wc_custom_field_value_to_order_notes', 10, 2 );
|
|
|
|
function wc_custom_field_value_to_order_notes( $order, $data ) {
|
|
$order->set_customer_note( isset( $data['new_order_notes'] ) ? $data['new_order_notes'] : '' );
|
|
}
|