llms_price( int $price, array $args = array() )

Get a formatted price price


Parameters Parameters

$price

(int) (Required) Price to display.

$args

(array) (Optional) Array of arguments.

Default value: array()


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/functions/llms.functions.currency.php

function llms_price( $price, $args = array() ) {

	extract(
		apply_filters(
			'llms_price_args',
			array_merge(
				array(
					'currency'           => '',
					'decimal_separator'  => get_lifterlms_decimal_separator(),
					'decimals'           => get_lifterlms_decimals(),
					'format'             => get_lifterlms_price_format(),
					'thousand_separator' => get_lifterlms_thousand_separator(),
					'trim_zeros'         => get_lifterlms_trim_zero_decimals(),
				),
				$args
			)
		)
	);

	$negative = $price < 0;
	$price    = apply_filters( 'raw_lifterlms_price', floatval( $negative ? $price * -1 : $price ) );
	$price    = apply_filters( 'formatted_lifterlms_price', number_format( $price, $decimals, $decimal_separator, $thousand_separator ), $price, $decimals, $decimal_separator, $thousand_separator );

	if ( 'yes' === $trim_zeros && $decimals > 0 ) {
		$price = llms_trim_zeros( $price );
	}

	$formatted_price = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="llms-price-currency-symbol">' . get_lifterlms_currency_symbol( $currency ) . '</span>', $price );
	$r               = '<span class="lifterlms-price">' . $formatted_price . '</span>';

	return apply_filters( 'llms_price', $r, $price, $args );
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.