crosspeaksoftware / woo-address-book

Gives your customers the option to store multiple shipping addresses and retrieve them on checkout.
GNU General Public License v2.0
38 stars 18 forks source link

Save Order Note with Addresses #134

Open TimBHowe opened 2 years ago

TimBHowe commented 2 years ago

Add the ability to save the order note with the addressbook so it can will be autofilled as well.

I was hoping to ask a quick question regarding the WooCommerce Address Book plugin for WordPress you are credited with authoring https://en-gb.wordpress.org/plugins/woo-address-book/ - is it possible to save the 'order notes' field data alongside the address information? The idea is that if a customer always has the same instruction for a particular address this would be auto-filled alongside the rest.

I am working on a client's site which uses the order notes field when a particular shipping option is selected, however I don't believe it currently saves that information which would be useful for what they have asked. The 'order notes' is a base WooCommerce feature found in woocommerce/templates/checkout/form-shipping.php and is part of the 'shipping' fields.

TimBHowe commented 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:

matt-h commented 2 years ago

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;
}