Skip to content
Last updated

WHMCS\Product\Pricing\Price

Class

Price per cycle formatting helper

Methods

__construct

public function __construct($price)

Initialise price object

Parameters

TypeNameDescription
array$price

Returns self

cycle

public function cycle()

Return billing cycle

Returns string

isFree

public function isFree()

Is the billing cycle one time?

Returns bool

isOneTime

public function isOneTime()

Is the billing cycle one time?

Returns bool

isRecurring

public function isRecurring()

Is the billing cycle recurring?

Returns bool

setup

public function setup()

Return setup fees

Returns \WHMCS\View\Formatter\Price\|null

price

public function price()

Return price

Returns \WHMCS\View\Formatter\Price

breakdown

public function breakdown()

Return breakdown pricing info

Returns array

toPrefixedString

public function toPrefixedString()

Format price as a prefixed currency string

Returns string

toSuffixedString

public function toSuffixedString()

Format price as a suffixed string

Returns string

toFullString

public function toFullString()

Format price as a full currency string (prefix, amount and suffix)

Returns string

getShortCycle

public function getShortCycle()

Get short two-letter version of billing cycle

Returns string

isYearly

public function isYearly()

Returns true if the price is a yearly price

Returns bool

isMonthly

public function isMonthly()

Returns true if the price is a monthly price

Returns bool

cycleInYears

public function cycleInYears()

Get billing cycle in year(s)

Returns string

yearlyPrice

public function yearlyPrice(): string

Get per year price

cycleInMonths

public function cycleInMonths()

Get billing cycle in month(s)

Returns string

monthlyPrice

public function monthlyPrice()

Get per month price

Returns string

oneTimePrice

public function oneTimePrice()

Get one time price

Returns string

breakdownPrice

public function breakdownPrice()

Get best available breakdown price

Returns string

breakdownPriceNumeric

public function breakdownPriceNumeric()

Get best available breakdown price as a number

Returns string

calculatePercentageDifference

public function calculatePercentageDifference($price, $decimalPlaces = 0)

Calculate percentage difference between two prices.

Will return the percentage discount from a given higher amount compared with the monthly amount from the current instantiated object.

Parameters

TypeNameDescription
float$priceHigher amount to be calculated against
int$decimalPlacesNumber of decimals. Default 0.

Returns float