Generate Coupon Docs#
Function#
<mvt:item name="generatecoupon" param="Generate_Coupon()" />
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.
Parameter |
Description |
---|---|
pricegroup_name |
This is the price group (discount) the coupon will reference |
code_prefix |
This is the prefix you want the code to start with. It will automatically be appended with random alphanumeric characters. |
eligibility |
Valid values are X / Current Customer – The custom MUST be logged in at the time the coupon is generated for this to work. It will generate a coupon tied to that specific customer. If this is selected and the customer is not logged in, no coupon will be generated.A / All Shoppers – Any shopper can use the coupon up to the Max Use / Max User Per Shopper settingsL / All Logged In Customers – Any customer who is logged in can use the coupon |
limit |
Number of days coupon is valid for, starting on the time it was generated |
maxusetot |
Total number of times the coupon can be used |
maxuseshp |
Total number of time a unique shopper can use the coupon |
storage_variable |
Variable to store generated coupon data |
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.
Default Example#
<mvt:item name="generatecoupon" param="Generate_Coupon()" />
Override Example#
<mvt:item name="generatecoupon" param="Generate_Coupon( 'my_discount', 'MYDISCOUNT', 'A', 10, 1, 1 )" />
Override Example With Custom Variable#
<mvt:item name="generatecoupon" param="Generate_Coupon( 'my_discount', 'MYDISCOUNT', 'A', 10, 1, 1, g.custom_variable )" />
<mvt:comment>
Tokens:
</mvt:comment>
&mvt:generatecoupon:coupon:code;
&mvt:generatecoupon:coupon:id;
&mvt:generatecoupon:coupon:custscope;
&mvt:generatecoupon:coupon:dt_end;
&mvt:generatecoupon:coupon:max_use;
&mvt:generatecoupon:coupon:max_per;
Debug Function#
Calling this function anywhere after a call to Generate_Coupon will output any errors registered during the coupon generation.
<mvt:item name="generatecoupon" param="Debug()" />