added shipping phone + email, but billing e-mail & phone display wrong
-
Hello,
We added 2 custom fields to our shipping adress with this functions :
// display shipping phone in checkout and my account edit shipping address add_filter( 'woocommerce_shipping_fields', 'add_shipping_phone_field' ); function add_shipping_phone_field( $fields ) { $fields['shipping_phone'] = array( 'label' => __('N° de téléphone du destinataire'), 'required' => true, 'class' => array( 'form-row-wide' ), 'priority' => 100, ); $fields['shipping_mail'] = array( 'label' => __('Email du destinataire'), 'required' => false, 'class' => array( 'form-row-wide' ), 'priority' => 100, ); return $fields; } // Editable field on admin order edit pages inside edit shipping section add_filter( 'woocommerce_admin_shipping_fields' , 'add_order_admin_edit_shipping_phone' ); function add_order_admin_edit_shipping_phone( $fields ) { // Include shipping phone as editable field $fields['phone'] = array( 'label' => __("Téléphone"), 'show' => '0' ); $fields['mail'] = array( 'label' => __("Email"), 'show' => '0' ); return $fields; } // Adding custom placeholder to woocommerce formatted address only on Backend add_filter( 'woocommerce_localisation_address_formats', 'admin_localisation_address_formats', 50, 1 ); function admin_localisation_address_formats( $address_formats ){ // Only in backend (Admin) if( is_admin() || ! is_wc_endpoint_url() ) { foreach( $address_formats as $country_code => $address_format ) { $address_formats[$country_code] .= "\n{phone}"; $address_formats[$country_code] .= "\n{mail}"; } } return $address_formats; } // Custom placeholder replacement to woocommerce formatted address add_filter( 'woocommerce_formatted_address_replacements', 'custom_formatted_address_replacements', 10, 2 ); function custom_formatted_address_replacements( $replacements, $args ) { $replacements['{phone}'] = ! empty($args['phone']) ? $args['phone'] : ''; $replacements['{mail}'] = ! empty($args['mail']) ? $args['mail'] : ''; return $replacements; } // Add the shipping phone value to be displayed on email notifications under shipping address add_filter( 'woocommerce_order_formatted_shipping_address', 'add_shipping_phone_to_formatted_shipping_address', 100, 2 ); function add_shipping_phone_to_formatted_shipping_address( $shipping_address, $order ) { global $pagenow, $post_type; // Not on admin order edit pages (as it's already displayed). if( ! ( $pagenow === 'post.php' && $post_type === 'shop_order' && isset($_GET['action']) && $_GET['action'] === 'edit' ) ) { // Include shipping phone on formatted shipping address $shipping_address['phone'] = $order->get_meta('_shipping_phone'); $shipping_address['mail'] = $order->get_meta('_shipping_mail'); } return $shipping_address; } // Remove double billing phone from email notifications (and admin) under billing address add_filter( 'woocommerce_order_formatted_billing_address', 'remove_billing_phone_from_formatted_billing_address', 100, 2 ); function remove_billing_phone_from_formatted_billing_address( $billing_address, $order ) { unset($billing_address['phone']); unset($billing_address['mail']); return $billing_address; }
I don’t know why, but in packing slip, those two detail goes to the good place, perhaps billing phone & billing e-mail are going to the wrong column :
you can see a capture here : https://ibb.co/DpJpvRc
The information in RED should go under biling adress.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘added shipping phone + email, but billing e-mail & phone display wrong’ is closed to new replies.