mycred_get_unique_coupon_code

Description

This function will generate a unique random code for coupons. The generated value is ensured to be unique.

This function is only available if the Coupons add-on is enabled.

Available since version 1.4

Returns

(string) Random coupon code, 12 characters long.

Parameters

Param Type Required Description
function mycred_get_unique_coupon_code(
No params
) { ... }

Examples

Example 1: Generate a unique coupon code.

$code       = mycred_get_unique_coupon_code();
$args       = array(
	'code'       => $code,
	'global_max' => 100,
	'value'      => 10,
	'expires'    => '2020-01-01'
);
$new_coupon = mycred_create_new_coupon( $args );