同時使用折價券+88折扣時,開立發票出現錯誤
andykao1026 opened this issue · comments
andykao1026 commented
綠界開發票也會有一樣的狀況
JerryLiu commented
JerryLiu commented
[更新] 11/14 經過線上測試後,還是有錯誤
單價計算錯誤,變成1 * 0.33 = 1元了 單價完全錯誤
原因是 number_format
會 return 一個 string
還會帶千分位
如果轉成 (float)
數字,會變成1
應該使用 round
就好
$itemsTmp = $order->get_items();
$itemsTmp 會變成一個 WC_Order_Item_Product
物件組成的 array
然後遍歷出來
[14-Nov-2023 04:41:11 UTC] ⭐ 一些數據 Array
(
[get_quantity] => 3
[get_subtotal] => 1197
[get_subtotal_tax] => 0
[get_total] => 917
[get_total_tax] => 0
)
JerryLiu commented
原本寫法完全是在瞎寫
用陣列的拿法去拿物件的屬性,居然不會出錯也是奇蹟了
ref: https://woocommerce.github.io/code-reference/classes/WC-Order-Item-Product.html
andykao1026 commented
錯誤已排除