• I would like to be able to show the shipping method on the generated invoices. I can see it on the Packing Slip.

    Is there a simple way to include this on the Invoice as well?

    Thanks!

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.