LLMS_Access_Plan::get_initial_price( array $price_args = array(), LLMS_Coupon|int|null $coupon = null, string $format = 'float' )

Get the initial price due on checkout.


Description Description

Automatically accounts for Trials, sales, and coupon discounts.


Top ↑

Parameters Parameters

$price_args

(array) (Optional) Arguments passed to the price getter function to generate the price.

Default value: array()

$coupon

(LLMS_Coupon|int|null) (Optional) Coupon ID, object, or null if no coupon is being used.

Default value: null

$format

(string) (Optional) Format the price to be returned. Options: html, raw, float (default).

Default value: 'float'


Top ↑

Return Return

(mixed)


Top ↑

Source Source

File: includes/models/model.llms.access.plan.php

335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
    // If it's free it's a bit simpler.
    if ( $this->is_free() ) {
 
        $ret = $this->get_free_pricing_text( $format );
 
    } else {
 
        $price_key = 'price';
 
        // Setup the price key name based on the presence of a trial or sale.
        if ( $this->has_trial() ) {
            $price_key = 'trial_price';
        } elseif ( $this->is_on_sale() ) {
            $price_key = 'sale_price';
        }
 
        $ret = $this->get_price( $price_key, $price_args, $format, $coupon );
 
    }
 
    /**
     * Filter an access plan's initial price due on checkout.
     *
     * @since 3.30.1
     *
     * @param mixed                $ret        Price due on checkout.
     * @param array                $price_args Arguments passed to the price getter function to generate the price.
     * @param LLMS_Coupon|int|null $coupon     Coupon ID, object, or `null` if no coupon is being used.
     * @param string               $format     Format the price to be returned. Options: html, raw, float (default).
     * @param LLMS_Access_Plan     $this       Access Plan object.
     */
    return apply_filters( 'llms_access_plan_get_initial_price', $ret, $price_args, $coupon, $format, $this );
 
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.40.0 Simplify logic by using new 4th argument ($coupon) of the get_price() method.
3.30.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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