What are some best practices for displaying additional information such as tax and shipping costs in a PHP template for XT Commerce?

When displaying additional information such as tax and shipping costs in a PHP template for XT Commerce, it is best practice to calculate these values separately and then display them clearly to the user. This can be achieved by retrieving the necessary data from the database or through any relevant APIs, performing the calculations, and then formatting and displaying the information in a user-friendly manner.

// Calculate tax and shipping costs
$taxRate = 0.08; // Example tax rate
$shippingCost = 5.00; // Example shipping cost

// Perform calculations
$taxAmount = $totalPrice * $taxRate;
$totalPriceWithTax = $totalPrice + $taxAmount;

// Display information
echo "Tax: $" . number_format($taxAmount, 2) . "<br>";
echo "Shipping: $" . number_format($shippingCost, 2) . "<br>";
echo "Total Price with Tax and Shipping: $" . number_format($totalPriceWithTax + $shippingCost, 2);