Introduction
The Feed Meta object for the Coupons add-On is an associative array containing the properties which determine the type of coupon and discount available.
$feed['meta'] = array(
'gravityForm' => 0,
'couponName' => 'test100',
'couponCode' => 'TEST100',
'couponAmountType' => 'percentage',
'couponAmount' => 100,
'startDate' => '',
'endDate' => '',
'usageLimit' => 20,
'isStackable' => false,
'usageCount' => 2,
);
Usage
We recommend accessing the $feed meta using the rgar() or rgars() functions, e.g.:
$conditional_logic_enabled = rgars( $feed, 'meta/feedCondition' );
if ( $conditional_logic_enabled ) {
// Conditional logic is enabled for this feed.
$logic_rules = rgars( $feed, 'meta/feed_condition_conditional_logic_object/conditionalLogic/rules' );
foreach ( $logic_rules as $rule ) {
// Process each conditional logic rule.
$field_id = rgar( $rule, 'fieldId' );
$operator = rgar( $rule, 'operator' );
$value = rgar( $rule, 'value' );
// Example: Use $field_id, $operator, and $value in your logic.
}
}
Properties
- gravityForm string
The form ID this coupon was created for. An ID of 0 indicates the coupon can be used with ALL forms.
-
couponName string
The coupon name.
-
couponCode string
The the value users should enter to apply this coupon to the form total.
-
couponAmountType string
The coupon amount type. Possible values: flat or percentage.
-
couponAmount string
The coupon amount.
-
startDate string
The date when the coupon should start.
-
endDate string
The date when the coupon should expire.
-
usageLimit integer
The number of times the coupon can be used.
-
isStackable boolean
Can this coupon be used in conjunction with another coupon? Default is false.
-
usageCount integer
The number of times this coupon has been used since the count was last reset.