Open jgangso opened 6 years ago
While writing, I came up with an workaround idea and it seemed to work, which I'm sharing here for future readers:
/** Workaround for https://github.com/kilbot/WooCommerce-POS/issues/195
* The POS may mix tax labels and amounts, thus we construct the label again based on the 'rate' property which is not being mixed
*/
function my_wcpos_handlebars_tax_label_helper( $js ) {
$inline_js =
'Handlebars.registerHelper("tax_label", function(rate) {
rate = parseInt(rate);
return ' . __('Tax ', 'your-textdomain') . ' + rate.toString() + " %";
});';
$js['my_wcpos_handlebars_tax_label_helper'] = $inline_js;
return $js;
}
add_filter( 'woocommerce_pos_enqueue_footer_js', 'my_wcpos_handlebars_tax_label_helper' );
This outputs simple "Tax XX %" label for each line, which is sufficient at least in my country (Finland).
Meanwhile, would be great to get this correct in the core plugin too. :+1:
Hi @kilbot
Could you please check this scenario:
Tax classes: Standard tax: 24 % Reduced tax: 14 % Itemized tax: Enabled
Steps to reproduce:
My observations so far:
Conclusions: I've tried to fix this by adjusting itemizedTax -function to mimic the sorting order of the POS.options.tax_rates, but that doesn't work due to the way Javascript traverses Objects (order not guaranteed). I also tried to unset the tax_lines from the local order before merging in order to use whatever the remote order includes, but that results in empty tax_lines after the merge, ie. the tax_lines of the remote order aren't being merged if the tax_lines of the local order don't exist.
Any suggestion on how to proceed? Thanks!