Php 删除商业购物车(按国家/地区估算)税务文本
我正在wordpress上建立一个网站,当我去购物车的时候,它会不断弹出 “为澳大利亚估算”税后即给出该项目的税收价值 我检查了另一个问题和答案在这里为同一件事,但他们有不同的代码,我的代码。我试过几种不同的方法,但都没办法解决 这是我在谷歌chrome上查看购物车时的代码Php 删除商业购物车(按国家/地区估算)税务文本,php,wordpress,woocommerce,cart,tax,Php,Wordpress,Woocommerce,Cart,Tax,我正在wordpress上建立一个网站,当我去购物车的时候,它会不断弹出 “为澳大利亚估算”税后即给出该项目的税收价值 我检查了另一个问题和答案在这里为同一件事,但他们有不同的代码,我的代码。我试过几种不同的方法,但都没办法解决 这是我在谷歌chrome上查看购物车时的代码 <tr class="tax-total"> <th>Tax <small>(estimated for Australia)</small></th>
<tr class="tax-total">
<th>Tax <small>(estimated for Australia)</small></th>
<td data-title="Tax">
<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol">$</span>109.80</span>
</td>
</tr>
税收(澳大利亚估算)
$109.80
有人能帮我找到一个过滤器修复程序吗?你可以通过编辑主题的WooCommerce购物车模板文件来完成。我猜这是在cart.php中硬编码的 或者,如果您想要更简单的解决方案,只需使用CSS将其隐藏即可 此代码隐藏“(估计为{country})”部分: 这个藏起来了
.tax-total {display:none!important}
你可以通过编辑你的主题的模板文件来完成。我猜这是在cart.php中硬编码的 或者,如果您想要更简单的解决方案,只需使用CSS将其隐藏即可 此代码隐藏“(估计为{country})”部分: 这个藏起来了
.tax-total {display:none!important}
负责该行为的函数是…但希望您可以使用以下代码挂钩函数来更改它:
add_filter( 'woocommerce_cart_totals_order_total_html', 'filtering_cart_totals_order_total_html', 20, 1 );
function filtering_cart_totals_order_total_html( $value ){
$value = '<strong>' . WC()->cart->get_total() . '</strong> ';
// If prices are tax inclusive, show taxes here.
if ( wc_tax_enabled() && WC()->cart->display_prices_including_tax() ) {
$tax_string_array = array();
$cart_tax_totals = WC()->cart->get_tax_totals();
if ( get_option( 'woocommerce_tax_total_display' ) == 'itemized' ) {
foreach ( $cart_tax_totals as $code => $tax ) {
$tax_string_array[] = sprintf( '%s %s', $tax->formatted_amount, $tax->label );
}
} elseif ( ! empty( $cart_tax_totals ) ) {
$tax_string_array[] = sprintf( '%s %s', wc_price( WC()->cart->get_taxes_total( true, true ) ), WC()->countries->tax_or_vat() );
}
if ( ! empty( $tax_string_array ) ) {
$value .= '<small class="includes_tax">' . sprintf( __( '(includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ) . '</small>';
}
}
return $value;
}
add_filter('woocommerce_cart_totals_order_total_html','filtering_cart_totals_order_total_html',20,1);
函数筛选\购物车\总计\订单\总计\ html($value){
$value=''.WC()->cart->get_total()。';
//如果价格含税,请在此处显示税费。
如果(wc_tax_enabled()&&wc()->cart->display_prices_include_tax()){
$tax_string_array=array();
$cart_tax_totals=WC()->cart->get_tax_totals();
如果(获取选项('woocommerce\u tax\u total\u display')=='itemized'){
foreach($cart\U tax\总计为$code=>$tax){
$tax\u string\u array[]=sprintf('%s%s',$tax->格式化金额,$tax->标签);
}
}elseif(!空($cart\u tax\u totals)){
$tax_string_array[]=sprintf('%s%s',wc_price(wc()->cart->get_taxes_total(true,true)),wc()->国家->税收或增值税());
}
if(!empty($tax\u string\u array)){
$value.=''.sprintf(uuuuuuuu('(包括%s)'woocommerce')、内爆('、'、$tax_字符串_数组))。';
}
}
返回$value;
}
代码进入活动子主题(或活动主题)的function.php文件。测试和工作
您将获得:
而不是:
这是对Woocommerce 3.2+的一个更新,根据以下答案略有不同:该行为的责任函数是…但希望您可以使用以下代码挂钩函数来更改:
add_filter( 'woocommerce_cart_totals_order_total_html', 'filtering_cart_totals_order_total_html', 20, 1 );
function filtering_cart_totals_order_total_html( $value ){
$value = '<strong>' . WC()->cart->get_total() . '</strong> ';
// If prices are tax inclusive, show taxes here.
if ( wc_tax_enabled() && WC()->cart->display_prices_including_tax() ) {
$tax_string_array = array();
$cart_tax_totals = WC()->cart->get_tax_totals();
if ( get_option( 'woocommerce_tax_total_display' ) == 'itemized' ) {
foreach ( $cart_tax_totals as $code => $tax ) {
$tax_string_array[] = sprintf( '%s %s', $tax->formatted_amount, $tax->label );
}
} elseif ( ! empty( $cart_tax_totals ) ) {
$tax_string_array[] = sprintf( '%s %s', wc_price( WC()->cart->get_taxes_total( true, true ) ), WC()->countries->tax_or_vat() );
}
if ( ! empty( $tax_string_array ) ) {
$value .= '<small class="includes_tax">' . sprintf( __( '(includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ) . '</small>';
}
}
return $value;
}
add_filter('woocommerce_cart_totals_order_total_html','filtering_cart_totals_order_total_html',20,1);
函数筛选\购物车\总计\订单\总计\ html($value){
$value=''.WC()->cart->get_total()。';
//如果价格含税,请在此处显示税费。
如果(wc_tax_enabled()&&wc()->cart->display_prices_include_tax()){
$tax_string_array=array();
$cart_tax_totals=WC()->cart->get_tax_totals();
如果(获取选项('woocommerce\u tax\u total\u display')=='itemized'){
foreach($cart\U tax\总计为$code=>$tax){
$tax\u string\u array[]=sprintf('%s%s',$tax->格式化金额,$tax->标签);
}
}elseif(!空($cart\u tax\u totals)){
$tax_string_array[]=sprintf('%s%s',wc_price(wc()->cart->get_taxes_total(true,true)),wc()->国家->税收或增值税());
}
if(!empty($tax\u string\u array)){
$value.=''.sprintf(uuuuuuuu('(包括%s)'woocommerce')、内爆('、'、$tax_字符串_数组))。';
}
}
返回$value;
}
代码进入活动子主题(或活动主题)的function.php文件。测试和工作
您将获得:
而不是:
这是对Woocommerce 3.2+的更新,根据以下答案略有不同: