Plugin Contributor
dwpriv
(@dwpriv)
You can try this code snippet
/**
* WP Overnight - PDF Invoices & Packing Slips for WooCommerce
* Custom function to display the shipping method in the invoice.
*
* @param string $document_type
* @param WC_Abstract_Order $order
*
* @return void
*/
function wpo_display_shipping_method( string $document_type, \WC_Abstract_Order $order ): void {
if ( 'invoice' !== $document_type ) {
return;
}
$document = wcpdf_get_document( $document_type, $order );
if ( ! empty( $document->get_shipping_method() ) ) {
echo '<tr class="shipping-method">
<th>', __( 'Shipping Method:', 'woocommerce-pdf-invoices-packing-slips' ), '</th>
<td>', $document->shipping_method(), '</td>
</tr>';
}
}
add_action( 'wpo_wcpdf_after_order_data', 'wpo_display_shipping_method', 10, 2 );
If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use code snippets. We also have a blog post here that you may find helpful about adding custom code to your site.