Hi @bacp,
Thank you for appreciating our plugin.
To add the shipping method, could you please try adding the below code and see whether it works or not.
Code:
/**
* Add this code snippet in functions.php file of your currently active theme.
* An example that adds a ‘VAT’ and ‘Customer Number’ field to the end of the list.
*/
function example_custom_order_fields( $fields, $order ) {
$new_fields = array();
if( get_post_meta( $order->id, ‘your_meta_field_name’, true ) ) {
$new_fields[‘your_meta_field_name’] = array(
‘label’ => ‘VAT’,
‘value’ => get_post_meta( $order->id, ‘your_meta_field_name’, true )
);
}
if( get_post_meta( $order->id, ‘your_meta_field_name’, true ) ) {
$new_fields[‘your_meta_field_name’] = array(
‘label’ => ‘Customer Number’,
‘value’ => get_post_meta( $order->id, ‘your_meta_field_name’, true )
);
}
return array_merge( $fields, $new_fields );
}
add_filter( ‘wcdn_order_info_fields’, ‘example_custom_order_fields’, 10, 2 );
Also, please make sure that the field itself should be meta-field.
Please let us know how it goes.
Regards,
Kenil Shah
Thread Starter
BACP
(@bacp)
I just used this code in the print-content.php and it worked
<h2>Shipping method<?php echo $order->get_shipping_method() ?></h2>
-
This reply was modified 5 years, 10 months ago by
BACP.
-
This reply was modified 5 years, 10 months ago by
BACP.
-
This reply was modified 5 years, 10 months ago by
BACP.
Hi @bacp,
Glad that the code worked for you. 🙂
Do let us know if you have any further queries.
Regards,
Kenil Shah