我需要把税从注册费中删除,我看不出有什么办法对订阅费征税,而不是注册费。
我试过使用过滤器:woocommerce_subscriptions_product_price_string。我只能设法打开或关闭注册费。
如何从注册费中扣除税款?
发布于 2017-11-22 00:46:28
这是正确的钩子使用,但它是不容易让它的工作。因此,这里是一个自定义函数,它连接在woocommerce_subscriptions_product_price_string中,它将取代显示的注册费价格“包括赋税”,由注册费价格(不包括税金)代替。
我已经分离了一个功能,您可以重新使用,价格注册费用。它将返回一系列的价格(有/没有税和税的价格)。
这是代码:
function get_price_sign_up_fee( $product ){
$price_incl_tax = wcs_get_price_including_tax( $product, array( 'price' => WC_Subscriptions_Product::get_sign_up_fee( $product ) ) );
$price_excl_tax = wcs_get_price_excluding_tax( $product, array( 'price' => WC_Subscriptions_Product::get_sign_up_fee( $product ) ) );
$price_tax = $price_incl_tax - $price_excl_tax;
return array( 'incl_tax' => $price_incl_tax, 'excl_tax' => $price_excl_tax, 'tax' => $price_tax );
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'subscr_product_price_string', 10, 3 );
function subscr_product_price_string( $subscription_string, $product, $include ){
//print_pr($subscription_string);
if ( $include['sign_up_fee'] && WC_Subscriptions_Product::get_sign_up_fee( $product ) > 0 ) {
$sign_up_fee = get_price_sign_up_fee( $product );
// Replacing price to excluding taxes one
$subscription_string = str_replace( wc_price($sign_up_fee['incl_tax']), wc_price($sign_up_fee['excl_tax']), $subscription_string );
}
return $subscription_string;
}代码在您的活动子主题(或主题)的function.php文件中,或者在任何插件文件中。
测试和工作。
但在购物车项目中,注册费用仍然与税收有关,…但这是另一回事(或另一个问题)…因此,您需要找到对其进行更改的方法,…。
https://stackoverflow.com/questions/47388949
复制相似问题