我的Woocommerce网站没有显示增值税,客户也不希望这样做。
我购买了WooCommerce打印发票/包装清单。
我想在表格的底部添加一行,并使用基于发票总额的简单计算计算发票中的增值税额。
我通过编辑order-table.php实现了这一点,但更喜欢通过向functions.php添加过滤器来添加它。
我看过https://docs.woocommerce.com/document/woocommerce-print-invoice-packing-list/,但似乎无法实现我的需要。
有人能指出我正确的方向吗?
由于
答案 0 :(得分:0)
我在搜索代码后找到了一个过滤器。我甚至添加了一些额外的代码来重新排序值,以便增值税出现在总数之前。如果你不想这样,我会发布解决方案而不重新排序。我已经加入10美元的虚拟价格,您可以用计算代替。
function modify_wc_pip_document_table_footer( $rows, $type, $order_id ) {
$tmp_rows = array();
$tmp_rows['cart_subtotal'] = $rows['cart_subtotal'];
$tmp_rows['payment_method'] = $rows['payment_method'];
$tmp_rows['vat'] = array( 'vat_total' => '<strong class="order-order_total">VAT Total:</strong>',
'value' => wc_price(10)
);
$tmp_rows['order_total'] = $rows['order_total'];
return $tmp_rows;
}
add_filter( 'wc_pip_document_table_footer', 'modify_wc_pip_document_table_footer', 10, 3 );
无需重新排序
function modify_wc_pip_document_table_footer( $rows, $type, $order_id ) {
$order = wc_get_order( $order_id );
$order_total = $order->get_total();
$rows['vat'] = array( 'vat_total' => '<strong class="order-order_total">VAT Total:</strong>',
'value' => wc_price(600)
);
return $rows;
}
add_filter( 'wc_pip_document_table_footer', 'modify_wc_pip_document_table_footer', 10, 3 );