I wrote a woocommerce plugin that creates the following custom checkout fields:
billing_street_name
billing_house_number
billing_house_number_suffix
shipping_street_name
shipping_house_number
shipping_house_number_suffix
I also added this to the admin pages, but since I cannot hook into get_formatted_billing_address & get_formatted_shipping_address (which are both used to display the addresses in writepanel-order_data.php and shop_order.php) I would like to copy them into the default billing_address_1 & shipping_address_1 like this:
billing_address_1 = billing_street_name + billing_house_number + billing_house_number_suffix
I tried to do this with the following (rudimentary) code:
add_action( 'woocommerce_process_checkout_field_billing_address_1', array( &$this, 'combine_street_number_suffix' ) );
public function combine_street_number_suffix () {
$key = $_POST['billing_street_name'] . ' ' . $_POST['billing_house_number'];
return $key;
}
but that doesn’t work – I don’t think the $_POST variable gets passed at all?
here’s how the hook is created in class-wc-checkout.php:
// Hook to allow modification of value
$this->posted[ $key ] = apply_filters( 'woocommerce_process_checkout_field_' . $key, $this->posted[$key] );
fixed this using the ‘woocommerce_checkout_update_order_meta’ hook:
I don’t think this code is very elegant though (the suffix check part specifically), so if anyone has tips on improving it – very welcome!