Viewing 1 replies (of 1 total)
  • Plugin Contributor Ewout

    (@pomegranate)

    Hi!
    You can do this by filtering the prices, add the following to your theme functions (read this if you haven’t edited functions.php before):

    add_action( 'wpo_wcpdf_process_template_order', 'wpo_wcpdf_before_pdf', 5, 2 );
    function wpo_wcpdf_before_pdf ( $template_type, $order_id ) {
        add_filter('wc_price', 'wcpdf_add_bgn_amount', 10, 3);
        // echo '<pre>';var_dump($template_type);echo '</pre>';die();
    }
    
    function wcpdf_add_bgn_amount( $formatted_price, $price, $args ) {
        extract( apply_filters( 'wc_price_args', wp_parse_args( $args, array(
            'ex_tax_label'       => false,
            'currency'           => '',
            'decimal_separator'  => wc_get_price_decimal_separator(),
            'thousand_separator' => wc_get_price_thousand_separator(),
            'decimals'           => wc_get_price_decimals(),
            'price_format'       => get_woocommerce_price_format()
        ) ) ) );
    
        // conversion rate
        $bgn_rate = 1.95802248;
        // convert EUR to BGN
        $bgn_price = $price * $bgn_rate;
    
        $negative        = $bgn_price < 0;
        $bgn_price       = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $bgn_price * -1 : $bgn_price ) );
        $bgn_price       = apply_filters( 'formatted_woocommerce_price', number_format( $bgn_price, $decimals, $decimal_separator, $thousand_separator ), $bgn_price, $decimals, $decimal_separator, $thousand_separator );
    
        if ( apply_filters( 'woocommerce_price_trim_zeros', false ) && $decimals > 0 ) {
            $bgn_price = wc_trim_zeros( $bgn_price );
        }
    
        $formatted_bgn_price = sprintf(' <span class="amount">(%s BGN)</span>', ( $negative ? '-' : '' ) . $bgn_price);
    
        return $formatted_price . $formatted_bgn_price;
    }

    Hope that helps!

    Ewout

Viewing 1 replies (of 1 total)
  • The topic ‘Using 2 different currencies inside invoice.’ is closed to new replies.