Description
This function checks if a coupon was successfully applied or not. Should be used in combination with the mycred_use_coupon function.
Returns
(bool) TRUE
if the coupon was successfully applied else FALSE
.
Parameters
Param | Type | Required | Description | |
---|---|---|---|---|
function mycred_coupon_was_successfully_used( |
||||
$code |
- | Yes | The results of the mycred_use_coupon function. |
|
) { ... } |
Example
Example 1: Apply a posted coupon code to the current user.
$user_id = get_current_user_id(); $code = $_POST['coupon']; $results = mycred_use_coupon( $code, $user_id ); if ( mycred_coupon_was_successfully_used( $results ) ) { // Coupon was successfully used } else { // Something went wrong }