LLMS_Access_Plan::get_initial_price( array $price_args = array(), $coupon_id = null, string $format = 'float' )
Get the initial price due on checkout.
Description Description
Automatically accounts for Trials, sales, and coupon discounts.
Parameters Parameters
- $price_args
-
(array) (Optional) Arguments passed to the price getter function to generate the price.
Default value: array()
- $coupond_id
-
(int|null) (Required) LLMS_Coupon ID or
null
if no coupon is being used. - $format
-
(string) (Optional) Format the price to be returned. Options: html, raw, float (default).
Default value: 'float'
Return Return
(mixed)
Source Source
File: includes/models/model.llms.access.plan.php
public function get_initial_price( $price_args = array(), $coupon_id = null, $format = 'float' ) { // If it's free it's a bit simpler. if ( $this->is_free() ) { $ret = $this->get_free_pricing_text( $format ); } else { // pricing function to use based on presence of coupon $func = $coupon_id ? 'get_price_with_coupon' : 'get_price'; // build args to pass to the function $args = array( $price_args, $format ); // coupons have an extra arg (coupon id) if ( $coupon_id ) { array_unshift( $args, $coupon_id ); } // setup the price key name based on the presence of a trial or sale if ( $this->has_trial() ) { array_unshift( $args, 'trial_price' ); } elseif ( $this->is_on_sale() ) { array_unshift( $args, 'sale_price' ); } else { array_unshift( $args, 'price' ); } // retrieve the price. $ret = call_user_func_array( array( $this, $func ), $args ); } /** * 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 int|null $coupond_id LLMS_Coupon ID 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_id, $format, $this ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.30.1 | Introduced. |
User Contributed Notes User Contributed Notes
Permalink: