【问题标题】:WC_Order->get_items() not populating `tax_class` fieldWC_Order->get_items() 未填充“tax_class”字段
【发布时间】:2016-07-23 17:43:04
【问题描述】:

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

这是我的代码:

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"]=> ...
}

我做错了什么?

【问题讨论】:

  • 这是正常的,当税类值是产品的默认值时:如果您查看数据库中的 postmeta_tax_class meta_key,对应的meta_valueempty

标签: php wordpress woocommerce orders tax


【解决方案1】:

答案是完全正常的

因为对于一个产品,当tax class value设置为default时,数据库中存储的对应数据为'meta_key' = '_tax_class' => 'meta_value' = ''所以值为空

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-06
    • 2021-05-06
    • 2022-11-26
    • 2012-01-22
    • 1970-01-01
    • 2011-03-09
    • 2017-01-28
    • 1970-01-01
    相关资源
    最近更新 更多