• Hello,

    This plugin looks awesome and better than

    PDF Invoices & Packing Slips for WooCommerce

    But transaction fee (Woocommerce/Stripe) is missing from invoice. What can I do to bring it there? I found old thread but it was about removing it. I want to add it 🙂

    Have a great day,

    John

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Ahmed Imran

    (@ahmedimran)

    Hi John,

    Thanks for the kind words!

    Transaction fees aren’t shown by default since WooCommerce/Stripe doesn’t store them in order totals. If your Stripe plugin saves the fee as order meta or a fee line, we can display it using a Challan hook.

    Could you tell us which Stripe plugin you’re using (WooCommerce Stripe Gateway, WooCommerce Payments, etc.) and share a screenshot of the Order Edit screen → Custom fields/meta showing where the fee is stored? Once we know the meta key (it varies by plugin), we’ll give you a tiny snippet to show it neatly on the invoice totals.

    Hook reference: https://webappick.com/docs/challan/customization/action-hooks-of-reference-woo-invoice/

    Thread Starter bfj6

    (@bfj6)

    Hello again,

    I’m using these:

    WooCommerce

    WooCommerce Tax (previously WooCommerce Shipping & Tax)

    WooPayments

    Screenshot:

    Plugin Support Ahmed Imran

    (@ahmedimran)

    Hello @bfj6 ,

    To achieve your goal, you can try the below code snippet in your themes functions.php or using a code snippet plugin.

    add_filter( 'wpifw_before_last_tr_free', function ( $html, $order, $template_type ) {
        $order = $order instanceof WC_Order ? $order : wc_get_order( $order );
        if ( ! $order ) return $html;
    
        $fee = 0.0;
        foreach ( $order->get_items( 'fee' ) as $item ) {
            $fee += (float) $item->get_total();
        }
        if ( ! $fee ) {
            foreach ( array( '_stripe_fee', '_paypal_fee', '_transaction_fee' ) as $k ) {
                $fee += (float) $order->get_meta( $k, true );
            }
        }
        if ( $fee <= 0 ) return $html;
    
        return $html . sprintf(
            '<tr class="transaction-fee"><td class="order-total-label">%s :</td><td class="order-total-value">%s</td></tr>',
            esc_html__( 'Transaction Fee', 'webappick-pdf-invoice-for-woocommerce' ),
            wc_price( $fee, array( 'currency' => $order->get_currency() ) )
        );
    }, 10, 3 );
    

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Transaction Fee’ is closed to new replies.