I have some custom fields in my shipping information that is not being displayed "properly" in the shipping information of orders under woocommerce -> orders -> order#. The cart and checkout pages are different via php code that changes a label. The cart image1 is the original\core label that is defined in shipping methods image2, this is being sent to the order information page. I would like the checkout information to show instead which is shown in image3. Image4 is how it currently looks under the order information. The code I use to change the shipping information on checkout and emails is below.
// Adjusting order and emails "shipping via" to show custom carrier name and number
add_filter( 'woocommerce_order_shipping_to_display_shipped_via', 'wdo_filter_order_shipping_to_display_shipped_via', 10, 2 );
function wdo_filter_order_shipping_to_display_shipped_via( $shipped_via, $order ) {
$carrier_name = $order->get_meta('carrier_name'); // Get carrier name
// Targeting orders with defined "carrier name" for "Custom Carrier" shipping method
if ( $carrier_name ) {
$carrier_number = $order->get_meta('carrier_number'); // get carrier number
$shipped_via = ' <small class="shipped_via">' . sprintf( __( 'via Custom Carrier: %s (%s)', 'woocommerce' ), $carrier_name, $carrier_number ) . '</small>';
}
return $shipped_via;
}
Cart page original label:
Defined under WooCommerce / Settings / Shipping:
Checkout shipping information and what I want to show under the order:
Shipping info under WooCommerce Admin > Orders > Edit Order: