Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在商业总额中增加一个百分比_Php_Wordpress_Woocommerce_Cart_Checkout - Fatal编程技术网

Php 在商业总额中增加一个百分比

Php 在商业总额中增加一个百分比,php,wordpress,woocommerce,cart,checkout,Php,Wordpress,Woocommerce,Cart,Checkout,在Woocommerce中,我正在使用插件,我想在总额上加上10%的GST 以下是一个例子(总计不含10%的GST): 结果应如下所示(合计10%的GST): 在产品列表页面上,以下是我所做的,以显示我想要的total: $woocommerce->cart->total = $woocommerce->cart->total + number_format(($woocommerce->cart->total * 10) /100, 2); 问题是,当我下

在Woocommerce中,我正在使用插件,我想在总额上加上10%的GST

以下是一个例子(总计不含10%的GST):

结果应如下所示(合计10%的GST):

在产品列表页面上,以下是我所做的,以显示我想要的total:

$woocommerce->cart->total = $woocommerce->cart->total + number_format(($woocommerce->cart->total * 10) /100, 2);
问题是,当我下订单时,我在付款页面上总共有
$220
,而不是
$242

如何在此处更新订单总数?
我们有没有办法在Woocommerce中对购物车总额征收10%的GST


注意:我尝试使用网络调用对其进行调试,发现Woocommerce正在发送包含所有产品的购物车阵列,其中包含一个总计,并且订单页面可能正在重新计算总计,不包括我使用上述代码块应用的GST。

以下代码将向总计添加10%:

add_filter( 'woocommerce_calculated_total', 'custom_cart_grand_total', 20, 2 );
function custom_cart_grand_total( $total, $cart ) {
    return $total * 1.10;
}
代码进入活动子主题(或活动主题)的function.php文件。测试和工作

$woocommerce->cart->total = $woocommerce->cart->total + number_format(($woocommerce->cart->total * 10) /100, 2);
add_filter( 'woocommerce_calculated_total', 'custom_cart_grand_total', 20, 2 );
function custom_cart_grand_total( $total, $cart ) {
    return $total * 1.10;
}