Hi @youngtuan,
Are you buy any chance using some type of plugin that records your net gain or are you just using WooCommerce (WC)?
I wonder how do you get the profit amount from every order. If not with a plugin, how do you know how much is it? If it’s with a perceptual calculation, you could get the total amount and work with it to calculate the profit.
Let’s say that you calculate the 20% of the total from every order as your profit, so you can use this code snippet to display that amount in your order data:
/**
* Calculate profit based on perceptual amount
*/
add_action( 'wpo_wcpdf_after_order_data', 'wpo_wcpdf_delivery_date', 10, 2 );
function wpo_wcpdf_delivery_date ($template_type, $order) {
if ($template_type == 'invoice') {
$total_amount = $order->get_total();
$profit_rate = 20; // Change this with your actual profit percentage
$profit_amount = wc_price( $total_amount * $profit_rate / 100 );
?>
<tr class="profit-amount">
<th>Profit:</th>
<td><?php echo $profit_amount; ?></td>
</tr>
<?php
}
}
If you haven’t worked with code snippets (actions/filters) or functions.php before, read this guide: How to use filters