嗨,目前我想获得woocommerce的税率名称.我有办法得到这张图片中圈出的价值:http://i.imgur.com/niSraFa.png
我目前的代码:
$items = $order->get_items();
$lineItem = array();
$productInfo = $orderInfo = array();
$order_items = array();
if ($items) foreach ($items as $item_key => $item_value) {
$_tax = new WC_Tax();
$_product = $order->get_product_from_item( $item_value );
$product_tax_class = $_product->get_tax_class();
$tax_class = $item_value['tax_class'];
Run Code Online (Sandbox Code Playgroud)
你会使用这个WC_Tax()->find_rates()方法.它需要一个数组作为参数,在您的情况下,它将array( 'country' => 'NO' )返回一组匹配的税率.这个数组的关键之一是label其中包含税率的名称.
$tax = new WC_Tax();
$country_code = 'NO'; // or populate from order to get applicable rates
$rates = $tax->find_rates( array( 'country' => $country_code ) );
foreach( $rates as $rate ){
$tax_rate_name = $rate['label'];
}
Run Code Online (Sandbox Code Playgroud)
要查找特定订单的适用税率,请使用订单上find_rates()的送货/开票地址填充数组中的值.
| 归档时间: |
|
| 查看次数: |
1973 次 |
| 最近记录: |