I wish to include different types of Taxes in different classes to be assigned to the products. Unfortunately with the code below I put all the taxes at the standard rate and so I have no way to assign them later to the products.
The problem is that I am unable to create new Additional Tax Classes in a programmatic manner.
$tax_data = array(
'tax_rate_country' => '*',
'tax_rate_state' => '*',
'tax_rate' => $tax_rate,
'tax_rate_name' => $tax_rate_name,
'tax_rate_priority' => 1,
'tax_rate_compound' => 0,
'tax_rate_shipping' => 1,
'tax_rate_order' => 0,
'tax_rate_class' => $tax_rate_class
);
$tax_rate_id = WC_Tax::_insert_tax_rate( $tax_data );
WC_Tax::_update_tax_rate_postcodes($tax_rate_id, wc_clean('*'));
WC_Tax::_update_tax_rate_cities($tax_rate_id, wc_clean('*'));
Can anybody help me?
2
Answers
I developed a function, which I reduced to a skeleton here, which works for me.