Created
March 9, 2018 16:46
-
-
Save woogists/db57f663951f9a77e91e180e0b6b8663 to your computer and use it in GitHub Desktop.
[WooCommerce Shipping Multiple Addresses] Adding additional fields to addresses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this filter to display the custom address fields in User >> Profile page.
add_filter( 'woocommerce_wcms_shipping_fields', 'custom_shipping_fields', 10, 2 );