Skip to content
  1. Extras
  2. msPromoCode2
  3. Snippets
  4. mspc2Generate

mspc2Generate

Generates a promo code after N seconds on the page and shows a popup to the user. Usually called on every page to track time on site.

Подсказка

Since 1.1.12 you can set lifetime and additional config options. For promo codes with lifetime under 24 hours, the popup shows a countdown.

Countdown for promo code with lifetimeCountdown for promo code with lifetime

Parameters

Main

NameDefaultDescription
format[a-zA-Z0-9]{12}Promo code format; regex-like syntax supported.
seconds90Seconds before generation. Counts only on pages where the snippet is called.
tpltpl.msPromoCode2.generateNotification template.

Promo code settings

NameDefaultDescription
listgeneratePromo code "List" field.
count1How many times the generated promo code can be applied.
discount10%Discount for the generated promo code.
descriptionDescription for the generated promo code.
showinfo1Show "yellow" warnings when applying the promo code.
oneunit0Apply discount to one product unit only.
onlycart0Show discounted price only in cart.
unsetifnull0Unset if cart has no products matching the promo code.
unsetifnull_msgMessage when unsetting. Works only with unsetifnull enabled.
oldprice0Apply only to products without old price.
lifetimePromo code lifetime in seconds. Use either this or startedon + stoppedon.
startedonPromo code start, timestamp. Use with stoppedon or with lifetime.
stoppedonPromo code end, timestamp. Use with startedon or with lifetime.

Examples

25% discount after 20 seconds on site

Generates a 25% discount promo code after 20 seconds and shows it to the user.

fenom
{'!mspc2Generate' | snippet: [
  'discount' => '25%',
  'seconds' => 20,
]}

With format prefix hello12345

Generates a promo code with prefix hello12345 after 90 seconds (default) and shows it to the user.

fenom
{'!mspc2Generate' | snippet: [
  'format' => 'hello[0-9]{5}',
]}

With countdown

Generates a 10% promo code after 20 seconds with 20 minute lifetime and shows a countdown.

Also sets description and "Show discounted price only in cart".

fenom
{'!mspc2Generate' | snippet: [
  'discount' => '10%',
  'seconds' => 20,
  'description' => 'Generated promo code',
  'onlycart' => true,
  'lifetime' => 60 * 20,
]}