Using Gravity Forms ‘gform_coupons_post_delete_coupon’ JavaScript event

The gform_coupons_post_delete_coupon Gravity Forms JavaScript event fires after a coupon is deleted from a field, allowing further actions to be performed.

Usage

gform.addAction('gform_coupons_post_delete_coupon', function(code, formId) {
// your custom code here
});

Parameters

  • code (string): The coupon code which was deleted.
  • formId (int): The ID of the current form.

More information

See Gravity Forms Docs: gform_coupons_post_delete_coupon

Examples

Display a custom message after coupon deletion

Display a custom message in the console when a coupon is deleted from the form.

gform.addAction('gform_coupons_post_delete_coupon', function(code, formId) {
console.log('The coupon with code: ' + code + ' was deleted from form #' + formId);
});

Trigger a custom function on coupon deletion

Trigger a custom function that performs additional actions when a coupon is deleted.

function myCustomFunction(code, formId) {
// perform additional actions
}
gform.addAction('gform_coupons_post_delete_coupon', function(code, formId) {
myCustomFunction(code, formId);
});

Change form field value after coupon deletion

Change the value of a form field when a coupon is deleted.

gform.addAction('gform_coupons_post_delete_coupon', function(code, formId) {
// Change the value of field with ID 5 to 'Coupon Deleted'
jQuery('#input_' + formId + '_5').val('Coupon Deleted');
});

Hide an element after coupon deletion

Hide an element with a specific class when a coupon is deleted.

gform.addAction('gform_coupons_post_delete_coupon', function(code, formId) {
// Hide all elements with the 'my-custom-element' class
jQuery('.my-custom-element').hide();
});

Add a CSS class to the form after coupon deletion

Add a CSS class to the form container when a coupon is deleted.

gform.addAction('gform_coupons_post_delete_coupon', function(code, formId) {
// Add the 'coupon-deleted' class to the form container
jQuery('#gform_wrapper_' + formId).addClass('coupon-deleted');
});