3
我有兩件事情要問: 第一個是我想通過這個代碼來獲得每個項目的稅率百分比的訂單在woocommerce:獲得在Woocommerce爲了每一個產品的稅率百分比
$items = $order->get_items();
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 = $_tax->get_rates($product_tax_class);
結果是空白的,所以我不知道代碼有什麼問題。
其次,標準費率始終顯示爲空白任務分類。它可能與沒有稅收產品混淆。有什麼不對的嗎?
在哪個鉤你正在嘗試此代碼? – WisdmLabs
如果您查看數據庫,「標準增值稅」有一個空的「tax_class_rate」。這就是爲什麼它是「空白」 –