LLMS_Post_Model::get_price( string $key, array $price_args = array(), string $format = 'html' )

Getter for price strings with optional formatting options


Description Description


Parameters Parameters

$key

(string) (Required) property key

$price_args

(array) (Optional) array of arguments that can be passed to llms_price()

Default value: array()

$format

(string) (Optional) format conversion method [html|raw|float]

Default value: 'html'


Top ↑

Return Return

(mixed)


Top ↑

Source Source

File: includes/abstracts/abstract.llms.post.model.php

	public function get_price( $key, $price_args = array(), $format = 'html' ) {

		$price = $this->get( $key );

		// handle empty or unset values gracefully
		if ( '' === $price ) {
			$price = 0;
		}

		if ( 'html' == $format || 'raw' === $format ) {
			$price = llms_price( $price, $price_args );
			if ( 'raw' === $format ) {
				$price = strip_tags( $price );
			}
		} elseif ( 'float' === $format ) {
			$price = floatval( number_format( $price, get_lifterlms_decimals(), '.', '' ) );
		} else {
			$price = apply_filters( 'llms_get_' . $this->model_post_type . '_' . $key . '_' . $format, $price, $key, $price_args, $format, $this );
		}

		return apply_filters( 'llms_get_' . $this->model_post_type . '_' . $key . '_price', $price, $key, $price_args, $format, $this );

	}

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.





Permalink: