| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/plugins/woocommerce/src/Internal/Email/ |
Upload File : |
<?php
/**
* OrderPriceFormatter class file.
*/
declare( strict_types = 1 );
namespace Automattic\WooCommerce\Internal\Email;
use WC_Abstract_Order;
use WC_Order_Item;
/**
* Helper class for formatting prices in order emails.
*
* @internal Just for internal use.
*/
class OrderPriceFormatter {
/**
* Gets item subtotal - formatted for display in emails.
*
* @param WC_Abstract_Order $order Order instance.
* @param WC_Order_Item $item Item to get unit price from.
* @param string $tax_display 'incl' or 'excl' tax display mode.
* @return string Formatted item subtotal.
*/
public static function get_formatted_item_subtotal( WC_Abstract_Order $order, WC_Order_Item $item, string $tax_display ): string {
$includes_tax = 'excl' !== $tax_display;
$item_subtotal = $order->get_item_subtotal( $item, $includes_tax );
return self::format_price( $order, $item_subtotal, $includes_tax );
}
/**
* Helper method to format price with or without tax.
*
* @param WC_Abstract_Order $order Order instance.
* @param float $amount The amount to format.
* @param bool $includes_tax Whether to include tax in the formatted price.
* @return string Formatted price string.
*/
private static function format_price( WC_Abstract_Order $order, float $amount, bool $includes_tax ): string {
return wc_price(
$amount,
array(
'ex_tax_label' => ( ! $includes_tax && $order->get_prices_include_tax() ) ? 1 : 0,
'currency' => $order->get_currency(),
)
);
}
}