PA_PurchasableItem
in package
The PuzzleAnywhere PurchasableItem class. It allows for an easy way to display a purchasable item such as a puzzle, puzzle bundle, or subscription.
Table of Contents
- $description : string
- A description of the purchasable item.
- $ends_at : string
- The datetime when the purchasable item is no longer available.
- $external_payment_production_id : float|null
- The external payment production ID.
- $external_payment_sandbox_id : float|null
- The external payment sandbox ID.
- $fixed_subscription : bool
- Denotes whether the subscription is 'fixed'.
- $free : bool
- Denotes whether the purchasable item is freely available.
- $id : int
- The purchasable item ID.
- $label : string
- The purchasable item parametrized label.
- $name : string
- The purchasable item display name.
- $price : float
- The purchasable item price.
- $purchased : bool
- Denotes whether the active user has purchased the item.
- $puzzle : PA_Puzzle|null
- The associated puzzle, if the purchasable item has one.
- $recurring : bool
- Denotes whether the purchasable item is a recurring purchase.
- $savings : float
- The purchasable item discount.
- $selected : bool
- Denotes whether the purchasable item is currently `selected` by the active user.
- $subscription : bool
- Denotes whether the purchasable item is a subscription.
- $subscription_ends_at : string|null
- The assigned end date for a 'fixed' subscription.
- $subscription_interval : string|null
- Denotes how long the subscription can last.
- $subscription_starts_at : string|null
- The assigned start date for a 'fixed' subscription.
- get_item_by_slug() : PA_PurchasableItem|null
- Retrieves a purchasable item by the item slug.
- is_free() : bool
- Denotes whether the `PA_PurchasableItem` is free.
- purchasable_item_url() : string
- Retrieves a relative purchasable item URL.
- subscription_year_intv() : int
- Parses the year interval of the purchasable item subscription.
Properties
$description
A description of the purchasable item.
public
string
$description
A description of the purchasable item.
$ends_at
The datetime when the purchasable item is no longer available.
public
string
$ends_at
The datetime when the purchasable item is no longer available.
$external_payment_production_id
The external payment production ID.
public
float|null
$external_payment_production_id
This is the PayPal payment ID for recurring payments.
The external payment production ID.
$external_payment_sandbox_id
The external payment sandbox ID.
public
float|null
$external_payment_sandbox_id
This is the PayPal payment ID for recurring payments.
The external payment sandbox ID.
$fixed_subscription
Denotes whether the subscription is 'fixed'.
public
bool
$fixed_subscription
A fixed subscription means that the subscription is only available starting at a specific date/ends at a specific date.
Denotes whether the subscription is 'fixed'.
$free
Denotes whether the purchasable item is freely available.
public
bool
$free
Denotes whether the purchasable item is free.
$id
The purchasable item ID.
public
int
$id
The purchasable item ID.
$label
The purchasable item parametrized label.
public
string
$label
The purchasable item parametrized label.
$name
The purchasable item display name.
public
string
$name
The purchasable item display name.
$price
The purchasable item price.
public
float
$price
The purchasable item price.
$purchased
Denotes whether the active user has purchased the item.
public
bool
$purchased
Denotes whether the active user has purchased the item.
$puzzle
The associated puzzle, if the purchasable item has one.
public
PA_Puzzle|null
$puzzle
The associated puzzle, if the purchasable item has one.
$recurring
Denotes whether the purchasable item is a recurring purchase.
public
bool
$recurring
Denotes whether the purchasable item is a recurring purchase.
$savings
The purchasable item discount.
public
float
$savings
The purchasable item discount.
$selected
Denotes whether the purchasable item is currently `selected` by the active user.
public
bool
$selected
This is publicly available to track purchase progress.
Denotes whether the purchasable item is currently
selected by the active user.
$subscription
Denotes whether the purchasable item is a subscription.
public
bool
$subscription
Denotes whether the purchasable item is a subscription.
$subscription_ends_at
The assigned end date for a 'fixed' subscription.
public
string|null
$subscription_ends_at
The assigned end date for a 'fixed' subscription.
$subscription_interval
Denotes how long the subscription can last.
public
string|null
$subscription_interval
Examples: 1.year, 52.week, 2.month`
Denotes how long the subscription can last.
$subscription_starts_at
The assigned start date for a 'fixed' subscription.
public
string|null
$subscription_starts_at
The assigned start date for a 'fixed' subscription.
Methods
get_item_by_slug()
Retrieves a purchasable item by the item slug.
public
static get_item_by_slug(string $slug) : PA_PurchasableItem|null
Parameters
- $slug : string
-
The purchasable item slug.
Return values
PA_PurchasableItem|null —The purchasable item.
is_free()
Denotes whether the `PA_PurchasableItem` is free.
public
is_free() : bool
Return values
bool —Denotes whether the PA_PurchasableItem is free.
purchasable_item_url()
Retrieves a relative purchasable item URL.
public
purchasable_item_url() : string
Return values
string —A relative purchasable item URL.
subscription_year_intv()
Parses the year interval of the purchasable item subscription.
public
subscription_year_intv() : int
Return values
int —The year interval of the purchasable item subscription.