Open TimBHowe opened 2 years ago
Might want to make this it's own field like "Delivery Instructions" and leave the order note as is
We suggest looking at the following:
wc_address_book_addresses
- Gets the customer's addresses with field valueswoocommerce_checkout_update_customer
- Update the customer data with the information entered on checkout.The Order Note field is its own checkout field which is not linked to the Billing or Shipping addresses. In order to have it linked to one of them would take a lot of override code in both the checkout in order to change it when selecting address. But you would also need to customize the WooCommerce core Edit Address pages to both show and save the custom fields to be able to save them to an address. This could get very messy having to deal with saving and retrieving the data.
A much easier solution would be to just add another Textarea field to either Billing or Shipping address. Something like this:
add_filter( 'woocommerce_shipping_fields', 'custom_override_shipping_fields' );
function custom_override_shipping_fields( $fields ) {
$fields['shipping_instructions'] = array(
'label' => __('Delivery Instructions', 'woocommerce'),
'placeholder' => esc_attr__(
'Notes about your order, e.g. special notes for delivery.',
'woocommerce'
),
'type' => 'textarea',
'class' => array( 'notes' )
);
return $fields;
}
Add the ability to save the order note with the addressbook so it can will be autofilled as well.