I am trying to change the shipped via in emails and in order information. I have a custom radio button with customer fields that are filled out only on the checkout page. Currently WooCommerce takes the label of the radio button but not the fields.
I would like to have the fields only in customer email and in the order information under woocommerce -> orders -> order#.
I can get it to change to text but lost on how to include the custom fields on a new line, which are carrier_name
and carrier_number
- these are the only fields that should show in both email and order information under WooCommerce.
The carrier_name
and carrier_number
are only available from the checkout page, not the cart page. When the 'Custom Carrier' is not selected it should print in email the correct shipping method, which I think it does by default but just wanted to include the requirement.
The third image shows the order information under woocommerce > orders > order#, this should show only carrier_name
and carrier_number
.
My code:
//adjusting emails to show custom carrier name and number
add_filter( 'woocommerce_order_shipping_to_display_shipped_via', 'wdo_remove_shipping_label_thnakyou_page_cart', 10, 2 );
function wdo_remove_shipping_label_thnakyou_page_cart($label, $method) {
$shipping_label = get_post_meta($order->id, 'carrier_name') ;
$shipping_label = 'Just Test!!!';
return $shipping_label;
}
1 The Carrier Info I want to show, under Custom Carrier
2 What I can currently get to send in email
3 Order Information from woocommerce -> orders -> order#
4 Order information without the code I put in, I changed the label using php code on checkout page different from cart page "Custom Carrier (Enter Details Next Page)" to checkout page "Custom Carrier":