Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Internal/Email
File: OrderPriceFormatter.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* OrderPriceFormatter class file.
[2] Fix | Delete
*/
[3] Fix | Delete
[4] Fix | Delete
declare( strict_types = 1 );
[5] Fix | Delete
[6] Fix | Delete
namespace Automattic\WooCommerce\Internal\Email;
[7] Fix | Delete
[8] Fix | Delete
use WC_Abstract_Order;
[9] Fix | Delete
use WC_Order_Item;
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Helper class for formatting prices in order emails.
[13] Fix | Delete
*
[14] Fix | Delete
* @internal Just for internal use.
[15] Fix | Delete
*/
[16] Fix | Delete
class OrderPriceFormatter {
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Gets item subtotal - formatted for display in emails.
[20] Fix | Delete
*
[21] Fix | Delete
* @param WC_Abstract_Order $order Order instance.
[22] Fix | Delete
* @param WC_Order_Item $item Item to get unit price from.
[23] Fix | Delete
* @param string $tax_display 'incl' or 'excl' tax display mode.
[24] Fix | Delete
* @return string Formatted item subtotal.
[25] Fix | Delete
*/
[26] Fix | Delete
public static function get_formatted_item_subtotal( WC_Abstract_Order $order, WC_Order_Item $item, string $tax_display ): string {
[27] Fix | Delete
$includes_tax = 'excl' !== $tax_display;
[28] Fix | Delete
$item_subtotal = $order->get_item_subtotal( $item, $includes_tax );
[29] Fix | Delete
return self::format_price( $order, $item_subtotal, $includes_tax );
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Helper method to format price with or without tax.
[34] Fix | Delete
*
[35] Fix | Delete
* @param WC_Abstract_Order $order Order instance.
[36] Fix | Delete
* @param float $amount The amount to format.
[37] Fix | Delete
* @param bool $includes_tax Whether to include tax in the formatted price.
[38] Fix | Delete
* @return string Formatted price string.
[39] Fix | Delete
*/
[40] Fix | Delete
private static function format_price( WC_Abstract_Order $order, float $amount, bool $includes_tax ): string {
[41] Fix | Delete
return wc_price(
[42] Fix | Delete
$amount,
[43] Fix | Delete
array(
[44] Fix | Delete
'ex_tax_label' => ( ! $includes_tax && $order->get_prices_include_tax() ) ? 1 : 0,
[45] Fix | Delete
'currency' => $order->get_currency(),
[46] Fix | Delete
)
[47] Fix | Delete
);
[48] Fix | Delete
}
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function