gf_coupons()get_submitted_coupon_codes()get_coupons_by_codes()insert_feed()
GFCoupons is the class which houses the main functionality of the Gravity Forms Coupons Add-on, it extends the GFFeedAddOn class which is part of the add-on framework. Below are a few functions which you may find useful when working on your own custom code.
gf_coupons()
The gf_coupons() function is used to return an instance of the GFCoupons class.
get_submitted_coupon_codes()
Retrieves any submitted coupon codes from the entry object.
$coupon_codes = gf_coupons()->get_submitted_coupon_codes( $form, $entry );
$form Form Object
The form object currently being processed.
$entry Entry Object
The entry object currently being processed.
Returns array | boolean
An array of coupon codes or false if no codes were submitted.
get_coupons_by_codes()
Retrieves the properties for the specified coupon codes.
$coupons = gf_coupons()->get_coupons_by_codes( $codes, $form );
$codes string | array
The codes for the coupons to be retrieved.
$form Form Object
The form object currently being processed.
Returns array|boolean
An associative array with the coupon code as key to the array containing that coupons properties. False if no coupon feeds were found.
insert_feed()
The insert_feed() method can be used to add new coupons.
$feed_id = gf_coupons()->insert_feed( $form_id, $is_active, $meta );
$form_id integer
The ID of the form this coupon can be used with or 0 if it can be used with all forms.
$is_active boolean
Is this coupon active or inactive.
$meta Coupons Feed Meta
An associative array containing the properties which determine the type of coupon and discount available.
Returns integer
The ID of the new feed.