WooCommerce 自定义支付网关:只需根据总订单显示额外费用

问题描述

我正在使用 WooCommerce 和 Woocrypt,并且在比特币支付网关中,我在网关中添加了以下代码:

<b class="bold-titel">Amount</b>
<span class="ngh-blocktext copywrap-address"><?php echo $order->get_total(); ?></span>

Ex,它显示,支付的总金额为:50$ 但我等着它显示 55 美元(50 美元 + 10% 没有添加我在此处插入的代码,这会更改总购物车)

我想知道是否可以向 get_total 命令添加 10% 的费用? 我不想在购物车中添加 10% 我只希望上面的代码显示 10% 的额外费用。 我有这个广告给客户,如果他们在那里订购免费商品,他将支付 10% 的额外费用。

我得到了:

add_action( 'woocommerce_cart_calculate_fees','custom_fee_based_on_cart_total',10,1 ); function
custom_fee_based_on_cart_total( $cart ) {

    if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;

    // The percentage
    $percent = 10; // 10%
    // The cart total
    $cart_total = $cart->cart_contents_total; 

    // The conditional Calculation
    $fee = $cart_total >= 25 ? $cart_total * $percent / 100 : 0;

    if ( $fee != 0 ) 
        $cart->add_fee( __( "Gratuity","woocommerce" ),$fee,false ); 
}

在总订单中增加费用。

我不想要这个,我只想要上面的代码显示get_total加上总量的10%。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)