Tribe__Tickets__Commerce__Currency::get_formatted_currency_with_symbol( int|float $amount, int $post_id, string|null $provider = null, boolean $html = true )
Get Formatted Currency According to a Provider with Symbol
Contents
Parameters
- $amount
-
(int|float) (Required) The amount to format.
- $post_id
-
(int) (Required) The id of the post with tickets.
- $provider
-
(string|null) (Optional) The ticket provider class name.
Default value: null
- $html
-
(boolean) (Optional) Whether to return with html wrap.
Default value: true
Return
(mixed)
Source
File: src/Tribe/Commerce/Currency.php
public function get_formatted_currency_with_symbol( $amount, $post_id, $provider = null, $html = true ) {
$amount = $this->get_formatted_currency( $amount, $post_id, $provider );
$currency = $this->get_currency_by_provider( $post_id, $provider );
$format = '%1$s%2$s';
if ( $html ) {
$format = '
<span class="tribe-formatted-currency-wrap tribe-currency-prefix">
<span class="tribe-currency-symbol">%1$s</span>
<span class="tribe-amount">%2$s</span>
</span>
';
}
if ( 'postfix' === $currency['placement'] ) {
$format = '%2$s%1$s';
if ( $html ) {
$format = '
<span class="tribe-formatted-currency-wrap tribe-currency-postfix">
<span class="tribe-amount">%2$s</span>
<span class="tribe-currency-symbol">%1$s</span>
</span>
';
}
}
$formatted = sprintf( $format, $currency['symbol'], $amount );
/**
* Filter the Formatted Currency with Symbol
*
* @since 4.11.0
*
* @param string $formatted The formatted amount.
* @param int $amount The original amount to be formatted.
* @param array $currency An array of currency formatting details.
* @param boolean $html Whether to return with html wrap.
*/
return apply_filters( 'tribe_format_amount_with_symbol', $formatted, $amount, $currency, $html );
}
Changelog
| Version | Description |
|---|---|
| 4.11.0 | Introduced. |