Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[WooCommerce Shipping Multiple Addresses] Adding additional fields to addresses
function custom_shipping_fields( $fields, $country ) {
$fields['shipping_test'] = array(
'label' => 'Test',
'placeholder' => 'Test'
);
return $fields;
}
add_filter( 'woocommerce_shipping_fields', 'custom_shipping_fields', 10, 2 );
function display_custom_shipping_fields( $formatted_address, $address ) {
if ( isset( $address['shipping_test'] ) ) {
$formatted_address .= '<br/>Test: '. $address['shipping_test'];
}
return $formatted_address;
}
add_filter( 'wc_ms_formatted_address', 'display_custom_shipping_fields', 10, 2 );
@iyut

This comment has been minimized.

Copy link

@iyut iyut commented Sep 30, 2021

Add this filter to display the custom address fields in User >> Profile page.

add_filter( 'woocommerce_wcms_shipping_fields', 'custom_shipping_fields', 10, 2 );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment