如何向所有交易添加基于百分比的附加费(加上附加税)

How to add a percentage based surcharge (plus tax of surcharge) to all transactions

我正在尝试在购物车和结账时从 Woocommerce 小计中添加基于百分比的费用。不过这个费用是不是小计的5%附加费+5%附加费的20%税。

我已经成功添加了 5% 的小计费用。但是,如何在上面加上 20% 的 $surcharge?

此外,此类更改是否也适用于电子邮件? (以及购物车/结帐)是

    add_action( 'woocommerce_cart_calculate_fees','custom_adminfee_surcharge' );
    function custom_adminfee_surcharge() {
      global $woocommerce;
        if ( is_admin() && ! defined( 'DOING_AJAX' ) )
            return;
$percentage = 0.05 * .20;
        $surcharge = ( $woocommerce->cart->subtotal + $woocommerce->cart->shipping_total ) * $percentage;   
        $woocommerce->cart->add_fee( 'Surcharge', $surcharge, true, '' );
    }

这应该是小计的 5%,然后是那 5% 的 20%...

add_action( 'woocommerce_cart_calculate_fees','custom_adminfee_surcharge' );
function custom_adminfee_surcharge() {
  global $woocommerce;
    if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;

    $percentage = ( $woocommerce->cart->subtotal + $woocommerce->cart->shipping_total ) * 0.05;
    $surcharge = $percentage * 0.20;
    $total_charges = $percentage + $surcharge;

    $woocommerce->cart->add_fee( 'Surcharge', $total_charges, true, '' );
}