User Guide
Plugin installation
If you have already installed the plugin, feel free to move to the next step.
- Navigate to Plugins / Add New and search for “RFS Gravity Forms Woocommerce Discounts” in the search box.
- Once you’ve found the plugin click on “Install Now” and then on “Activate“.
License
In order to use the add-on you need to activate it in plugin global settings. The free version does not require the license and is activated when you activate the plugin.
Global Settings
To access global settings of the add-on:
- Go to Forms / Settings / Woo Discounts
- The available settings are:
- License key – Enter the license key you received after you purchased the plugin in order to activate the add-on.
- Allow customers to remove applied coupons – Useful when coupon is set to be added to the cart automatically.
Configuration
The configuration of the add-on is done on per forms basis. In order to do that, kindly follow these steps:
- Go to Forms, next hover the mouse cursor over the “Settings” link and then click on “Woo Discounts“.
- You will be taken to the settings page:
- If you select “Create new coupon” for the Discount coupon type option, you will see the advanced settings for the Discount coupon:
- The settings page consists of three groups of settings:
General:
- Enable discounts – Switch the feature on / off for the form.
- Discount delivery – Select discount delivery method. There are three methods available:
- Apply to cart (PRO) – The coupon code is applied to the cart automatically after successful form submission.
- Send via email (PRO) – The coupon code is send via email after successful form submission.
- Display in confirmation – The coupon code is displayed in the confimation message after successful form submission.
- Discount coupon type – Select type of the coupon. There are two types available:
- Existing coupon – Select existing Woocommerce coupon
- Create new coupon (PRO) – Creates / generates a new Woocommerce coupon on the fly when the form is submitted.
Discount Coupon (Existing coupon type):
- Coupon – Select an existing Woocommerce coupon
Discount Coupon (Create new coupon) (PRO):
- The settings for creating a new coupon are the same as for the Woocommerce coupons.
Email:
- Email subject – Set your own subject for the email.
- Email from – By default site admin email address is used. You can set your own using this setting.
- Email message (PRO) – Default value for this field is: “Your discount coupon code is: {discount_code}”. This setting lets you customize the message as well as personalize it using the dynamic merge tags for displaying form fields values, like Name for example.
For Developers
The plugin provides some helpful hooks and filters for developers:
1. rfs_gf_woo_disc_before_coupon_delivery
This hook is fired before the coupon code has been delivered using any of the delivery methods. You can use this to perform custom actions.
Usage
add_action( 'rfs_gf_woo_disc_before_coupon_delivery', 'rfswp_gf_wd_before_coupon_delivery_callback', 10, 3 );
Code language: PHP (php)
Parameters
- $form_info array
An array containing current form data. - $coupon_code string
Coupon code value. - $discount_delivery array
Active delivery methods.
2. rfs_gf_woo_disc_after_coupon_delivery
This hook is fired before the coupon code has been delivered using any of the delivery methods. You can use this to perform custom actions.
Usage
add_action( 'rfs_gf_woo_disc_after_coupon_delivery', 'rfswp_gf_wd_after_coupon_delivery', 10, 3 );
Code language: PHP (php)
Parameters
- $form_info array
An array containing current form data. - $coupon_code string
Coupon code value. - $discount_delivery array
Active delivery methods.
3. rfs_gf_woo_disc_coupon_created
This hook is fired after the coupon code has been created. It fires when “Create new coupon” option has been selected. You can use this to perform custom actions.
Usage
add_action( 'rfs_gf_woo_disc_coupon_created', 'rfswp_gf_wd_coupon_created', 10, 3 );
Code language: PHP (php)
Parameters
- $form_info array
An array containing current form data. - $coupon_id int
Newly created coupon code post id. - $coupon_code string
Newly created coupon code value.
4. rfs_gf_woo_disc_custom_coupon_code
This filter provides the ability to modify the newly created coupon code. It fires when “Create new coupon” option has been selected. Whe using this filter you also need to update the coupon code post data.
Usage
add_filter( 'rfs_gf_woo_disc_custom_coupon_code', 'rfswp_gf_wd_custom_coupon_code', 10, 3 );
Code language: PHP (php)
Parameters
- $coupon_code string
Newly created coupon code value. - $coupon_id int
Newly created coupon code post id. - $form_info array
An array containing current form data.
5. rfs_gf_woo_disc_coupon_code_length
This filter can be used to modify the auto-generated coupon code length (8 characters by default). It is used when “Create new coupon” option has been selected.
Usage
add_filter( 'rfs_gf_woo_disc_coupon_code_length', 'rfswp_gf_wd_coupon_code_length', 10, 1 );
Code language: PHP (php)
Parameters
- $length int
Coupon code length.
6. rfs_gf_woo_disc_allow_send_email
This filter can be used to prevent the email from being sent, for whatever reason like using your own function to send it.
Usage
add_filter( 'rfs_gf_woo_disc_allow_send_email', 'rfswp_gf_wd_allow_send_email', 10, 3 );
Code language: PHP (php)
Parameters
- $allow boolean
- $form_info array
An array containing current form data. - $post_data array
An array containing request data.
7. rfs_gf_woo_disc_select2_selected_value
This filter is used to modify the select 2 fields returned values. The field is used in form coupon settings.
Usage
add_filter( 'rfs_gf_woo_disc_select2_selected_value', 'rfswp_gf_wd_select2_selected_value', 10, 3 );
Code language: PHP (php)
Parameters
- $value array
An array containing field id and text, required by the select2 library. - $value_id string
The object id, either post or taxonomy term. - $taxonomy boolen
Whether the value_id is a taxonomy term id.
8. rfs_gf_woo_disc_form_info
This filter provides the ability to add custom data to the form info array, which contains some useful data of the currently processed form.
Usage
add_filter( 'rfs_gf_woo_disc_form_info', 'rfswp_gf_wd_form_info', 10, 2 );
Code language: PHP (php)
Parameters
- $form_info array
An array containing current form data. - $form array
Original Gravity Forms array containing the form data.
9. rfs_gf_woo_disc_settings
This filter is used to customize the available settings for the add-on, the form Email Verification settings fields. You can add your own group of settings using this filter.
Usage
add_filter( 'rfs_gf_woo_disc_settings', 'rfswp_gf_wd_settings', 10, 1 );
Code language: PHP (php)
Parameters
- $settings array
An array of settings groups and fields
10. rfs_gf_woo_disc_global_settings
This filter is used to customize the available global settings for the add-on. You can add your own group of settings using this filter.
Usage
add_filter( 'rfs_gf_woo_disc_global_settings', 'rfswp_gf_wd_global_settings', 10, 1 );
Code language: PHP (php)
Parameters
- $settings array
An array of settings groups and fields
11. rfs_gf_woo_disc_email_message
This filter can be used to modify the email message or using your custom email template.
Usage
add_filter( 'rfs_gf_woo_disc_email_message', 'rfswp_gf_wd_email_message', 10, 3 );
Code language: PHP (php)
Parameters
- $message html
- $form_settings array
An array containing form settings values. - $post_data array
An array containing request data
12. rfs_gf_woo_disc_email_from_name
This filter can be used to modify the email “from name”, which is a blog name by default.
Usage
add_filter( 'rfs_gf_woo_disc_email_from_name', 'rfswp_gf_wd_email_from_name', 10, 3 );
Code language: PHP (php)
Parameters
- $from_name string
- $form_settings array
An array containing form email verification settings values. - $post_data array
An array containing request data