### [How to Create a Default Prefix for Your Coupons](https://wpforms.com/developers/how-to-create-a-default-prefix-for-your-coupons/)

**Published:** October 18, 2023
**Author:** Editorial Team

**Excerpt:** This tutorial will show you how easy it is to set up a default prefix for your coupons when using the Coupons addon. 

**Content:**

## Overview

Are you eager to establish a default prefix for your WPForms coupons, streamlining your coupon management process? In this tutorial, we’ll delve into the seamless process of setting up a default prefix for your coupons using PHP. This not only simplifies coupon management but also adds a professional touch to your promotional efforts. Join us as we guide you through the steps, making the coupon generation process smoother and more efficient.

This snippet only generates the prefix when using the **Generate Code** button. However, it’s important to note that for any manually created coupons, you’ll be required to insert the prefix manually as this automated process applies exclusively to coupons generated using the automatic function.

## Adding the snippet

First, we’re going to add the snippet to our site. If you’re not sure how or where to add snippets, [please review this helpful documentation](https://wpforms.com/developers/how-to-add-custom-php-or-javascript-for-wpforms/ "How to Add Custom PHP or JavaScript for WPForms").

```

/**
 * Set default default prefix for coupons
 * 
 * @link   https://wpforms.com/developers/how-to-create-a-default-prefix-for-your-coupons/
 */

function  wpf_coupons_generator_generate_code_args ( $default ) {
 
	// Default prefix for the coupon
	$default[ 'prefix' ]      = 'WPFORMS-';

	return $default;
	
}

add_filter( 'wpforms_coupons_generator_generate_code_args', 'wpf_coupons_generator_generate_code_args', 10, 1 );
```

For the purpose of this documentation, we want our default prefix to be **WPFORMS-** for all of our automatically created coupons. Please remember to change this prefix to match what fits your needs.

## Creating the coupon

Once the snippet is added, it’s time to create a new coupon.

For this step, login in to your WordPress site. From the menu, select **WPForms** then click **Payments** and on the **Coupons** tab click **Add Coupon**.

Give your coupon a name that makes sense to you and then click the **Generate Coupon** button. You’ll see the prefix is now added.

![now you will see a default prefix on your coupons when you click the Generate Coupon button](https://wpforms.com/wp-content/uploads/2023/10/wpforms-default-prefix-coupon-code.jpg)

To learn more about working with the **Coupons** addon, [please review this documentation](https://wpforms.com/docs/coupons-addon/ "Coupons Addon").

## Related

Filter Reference: [wpforms\_coupons\_generator\_generate\_code\_args](https://wpforms.com/developers/wpforms_coupons_generator_generate_code_args/ "Using the wpforms_coupons_generator_generate_code_args filter")

## FAQ

#### Q: Are there other settings that I can set up for default?

**A:** Absolutely, you can set a **prefix**, **suffix**, **code length** and the **allowed characters** to make generating your coupon codes so much easier and uniform.

Take a look at this snippet to see an example.

```

/**
 * Set default args for the Coupon Addon
 * 
 * @link   https://wpforms.com/developers/wpforms_coupons_generator_generate_code_args/
 *
 * @param  array $default Set coupon default args
 * @return array
 */

function  wpf_coupons_generator_generate_code_args ( $default ) {
 
	// Set your defaults below
	// Default prefix for the coupon
	$default[ 'prefix' ]      = 'WPFORMS-';
	
	// Default suffix for the coupon
	$default[ 'suffix' ]      = '-COUPON';
	
	// Default allowed characters for the coupon
	$default[ 'characters' ]  = 'ABCDEFGHJKMNPQRSTUVWXYZ23456789';
	
	// Default length for the coupon
	$default[ 'code_length' ] = 20;

	return $default;
	
}

add_filter( 'wpforms_coupons_generator_generate_code_args', 'wpf_coupons_generator_generate_code_args', 10, 1 );
```

**Categories:** Snippets

**Tags:** Coupons, PHP

---

