隨着WooCommerce,我使用Traveler溢價主題集「零稅」率的一些定製預訂產品類型
我需要停用(TAX)在旅遊和酒店,我嘗試使用此代碼它:
add_filter('woocommerce_product_tax_class', 'wc_diff_rate_for_user', 1, 2);function wc_diff_rate_for_user($tax_class, $cart_item) {
if (is_admin() && ! defined('DOING_AJAX'))
return;
// Define HERE your targeted products IDs
$products_ids_arr = array(12 ,15, 24);
// Define HERE your targeted user roles
$users_role_arr = array('administrator', 'userrolename');
//Getting the current user data
$user_data = get_userdata(get_current_user_id());
foreach ($users_role_arr as $user_role)
if (in_array($user_role, $user_data->roles) && in_array($cart_item->id, $products_ids_arr)) {
$tax_class = 'Zero Rate';
break;
}
return $tax_class;}
來此代碼從這樣的回答:Tax class "Zero rate" per user role on specific product ID's
但也沒辦法,這是不是選項。我不能讓它工作,只爲旅遊和酒店滅稅。
我需要一些幫助,瞭解如何才能在WooCommerce中爲我的主題中的旅遊和酒店實現禁用稅。
重要更新
我用這一點和平的代碼輸出從車我自定義的產品類型,在那裏我有3種不同的產品類型:
add_action('woocommerce_before_cart_table','output_cart_raw_data');
function output_cart_raw_data(){
$count = 0;
foreach(WC()->cart->get_cart() as $cart_item){
$count++;
echo 'Product ' . $count . ' has a post type of: ' . $cart_item['st_booking_data']['st_booking_post_type'] . '<br>;
}
}
它在我的購物車頁上的輸出(使用的產品類型):
Product 1 has a post type of: st_tours
Product 2 has a post type of: st_hotel
Product 3 has a post type of: st_activity
我怎樣才能得到'Zero Tax'
激活的st_tours
和st_activity
產品類型?
感謝
模板這個https://themeforest.net/item/traveler-traveltourbooking-wordpress-theme/10822683 –
@LoicTheAztec它是一種預訂系統,在woocommerce的配置中主動爲所有物品徵稅,主題不具有對遊覽和活動禁用稅收的功能,當預訂到遊覽時,主題創建woocommerce產品,但將地點稅,我需要刪除只有旅遊和活動稅 –
@LoicTheAztec我的英語是好,我可以給你發送主題嗎?你幫助我嗎?非常感謝編輯我的問題! –