Display price suffix on WooCommerce emails

I'm looking for a way to display a price suffix in the WooCommerce emails. Like: ex.VAT Is there a short snippet to do this? enter image description here

Upvotes: 1

Views: 475

Answers (2)

tiny
tiny

Reputation: 465

You can make this customization without changing template files, by filtering woocommerce_order_formatted_line_subtotal Like this:

add_filter( 'woocommerce_order_formatted_line_subtotal', 'BN_add_price_suffix_subtotal', 10, 3 );

function BN_add_price_suffix_subtotal( $subtotal ) {
    
    $suffix =' ex. VAT';
    return $subtotal . $suffix;
}

Add this to the functions.php file in your child theme.

Upvotes: 0

Valerii Vasyliev
Valerii Vasyliev

Reputation: 469

Copy the file found at

wp-content/plugins/woocommerce/templates/emails/email-order-items.php -> wp-content/themes/your-theme/woocommerce/emails/email-order-items.php

into your store’s child theme .

Note that if you customize the parent theme rather than the child theme, any changes will be overwritten with theme updates.

Change code in wp-content/themes/your-theme/woocommerce/emails/email-order-items.php

Before

<td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
            <?php echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); ?>
</td>

After

<td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; vertical-align:middle; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;">
            <?php echo wp_kses_post( $order->get_formatted_line_subtotal( $item ) ); ?> ex. VAT
</td>

Upvotes: 6

Related Questions