WC_Order-> get_items()没有填充`tax_class`字段

时间:2016-04-04 08:56:21

标签: php wordpress woocommerce orders tax

在Woocommerce中,var_dumping订单会显示一个空字段tax_class,但税级会定义并正确分配给产品。

enter image description here

enter image description here

这是我的代码:

array(13) {
  ["name"]=>
  string(14) "Nuovo prodotto"
  ["type"]=>
  string(9) "line_item"
  ["item_meta"]=> ...
  ["item_meta_array"]=> ...
  ["qty"]=>
  string(1) "1"
  ["tax_class"]=>
  string(0) "" <-- this shouldn't be empty
  ["product_id"]=>
  string(2) "54"
  ["variation_id"]=>
  string(1) "0"
  ["line_subtotal"]=>
  string(6) "5.8824"
  ["line_total"]=>
  string(6) "5.8824"
  ["line_subtotal_tax"]=>
  string(6) "1.2941"
  ["line_tax"]=>
  string(6) "1.2941"
  ["line_tax_data"]=> ...
}

我做错了什么?

1 个答案:

答案 0 :(得分:1)

答案是完全正常的

因为对于产品,当在默认上设置税级类值时,存储在数据库中的相应数据为'meta_value' = '' =&gt; query = "SELECT movie_name from movie2 Where movie_id=(SELECT movie_id from rental where client_username='" & currentUser & "' AND start_date<='" & Format(Now, "yyyy-MM-dd") & "' AND return_date>='" & Format(Now, "yyyy-MM-dd") & "')" 因此值为空