mycred_get_coupon
Description
This function returns a coupon object based on a coupon post ID.
This function is only available if the Coupons add-on is enabled.
Available since version 1.7
Returns
(bool | object) Returns the coupon object or FALSE if the coupon post ID is invalid.
Coupon Object Example
Std Object
(
[post_id] => 1
[code] => 'ABC123'
[value] => 10.00
[point_type] => 'mycred_default'
[max_global] => 100
[max_user] => 1
[requires_min] => 0
[requires_min_type] => 'mycred_default'
[requires_max] => 0
[requires_max_type] => 'mycred_default'
[used] => 0
[expires] => false
[expires_unix] => false
)Parameters
| Param | Type | Required | Description | |
|---|---|---|---|---|
function mycred_get_coupon( |
||||
$coupon_post_id |
int | Yes | The coupon post object ID. |
|
) { ... } |
||||
Examples
Example 1: Get a coupons point value.
$coupon_id = 1; $coupon = mycred_get_coupon( $coupon_id ); printf( 'This coupon gives %d points.', $coupon->value );