I wish to display the full price that the customer paid for the item, rather than 'price without tax' and 'tax'.
I followed this: Woocommerce - Admin Order Detail Page and it almost gets me what I want, however it is not perfect to my case and I am failing to modify it. I am not very experienced in PHP and worried about breaking anything as it is a live webshop.
I managed to change the currency sign easily enough and put it at the end of the price rather than the start, but there's a couple of other things I wish to change and I'm not sure how/where.
We use commas instead of periods as decimal points. This is reflected without a problem everywhere else, but not with this custom snippet. How do I change this?
In the case of free item/shipping, this is empty. I tried to change "if $val>0" to just "if $val" but it made no difference.
I'd like this entire column to be on the right (as the last column) rather than on the left. So it reads Quantity, Total, Tax, Total incl. Tax.
Here is my current, slightly modified code:
function action_woocommerce_admin_order_item_values( $null, $item, $absint ) {
$val = ($item['type'] == 'line_item' || $item['type'] == 'shipping') ? $item['total'] + $item['total_tax'] : ' ';
$valdecimal = wc_format_decimal( $val, $dp='', $trim_zeros );
?>
<td class="item_fcost" data-sort-value="<?php echo $val; ?>">
<div class="view" style="font-weight: bold; text-align: right; padding-right: 10px;">
<?php if ($val) echo $valdecimal; echo ' DKK'; ?>
</div>
</td>
<?php
};
add_action( 'woocommerce_admin_order_item_values', 'action_woocommerce_admin_order_item_values', 10, 3 );
function action_woocommerce_admin_order_item_headers( $order ) {
echo '<th class="item_fcost sortable" data-sort="float" style="text-align: right;">Pris inkl. moms</th>';
};
add_action( 'woocommerce_admin_order_item_headers', 'action_woocommerce_admin_order_item_headers', 10, 3 );
Edit: I found out that this code also breaks/throws a fatal error with refunded orders. I've had to deactivate the code entirely.
I'm not experienced enough to know how to modify it and am still looking for help.