How can one efficiently calculate and display the VAT (MwSt) in a PHP script for an e-commerce platform like XT Commerce?

To efficiently calculate and display VAT (MwSt) in a PHP script for an e-commerce platform like XT Commerce, you can create a function that takes the price of the product as input, calculates the VAT amount based on a predefined rate, and then adds it to the original price to display the total price with VAT included.

function calculateVAT($price) {
    $vatRate = 0.19; // 19% VAT rate
    $vatAmount = $price * $vatRate;
    $totalPrice = $price + $vatAmount;
    
    return number_format($totalPrice, 2); // Display total price with 2 decimal places
}

// Example of how to use the function
$productPrice = 100; // Price of the product
$totalPriceWithVAT = calculateVAT($productPrice);
echo "Total price with VAT: €" . $totalPriceWithVAT;