24/7 Support: 800.608.6482

Template Language

Generate Coupon Docs

Function:

Note: If no parameters are passed, the function will use the configuration options set in the admin.

Parameters:

This function has 7 parameters which can be used to override the page default settings.

pricegroup_name

code_prefix

eligibility (valid values are X, A, or L for Current Customer, All Shoppers, or All Logged In Customers)

limit

maxusetot

maxuseshp

storage_variable

Parameter Definitions:

Code – This is the prefix you want the code to start with. It will automatically be appended with random alphanumeric characters.

Eligibility – There are three options here

Discount To Apply – This is the price group (discount) the coupon will reference

Limit Eligibility – Number of days coupon is valid for, starting on the time it was generated

Max Use (Total) – Total number of times the coupon can be used

Max Use (Per Shopper) – Total number of time a unique shopper can use the coupon

Description:

Calling Generate_Coupon() without parameters will generate a coupon using the configuration on the Generate Coupon tab. To override these settings for additional coupons pass the first six parameters listed above to the function. By default, all of the generated coupon data is stored in the l.settings:generatecoupon:coupon variable. Optionally, you may save the coupon details to a custom variable by passing the variable name as the seventh parameter.

Debug Function:

Parameters:

(none)

Description:

Calling this function anywhere after a call to Generate_Coupon will output any errors registered during the coupon generation.

Examples:

Looking for Developer Docs?

We have a whole section for that, including: Developer Training Series, Template Language docs, Module Development tutorials and much, much more.

Head to the Developer Section

Copyright © 1997 – 2026 Miva®, Miva Merchant®, MivaPay Vault®, Camp Miva®, Miva Connect®, Vexture℠, Miva, Inc. All Rights Reserved.