Skip to content

Latest commit

 

History

History

generate-a-discount-code-when-a-certain-product-is-purchased

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Generate a discount code when a certain product is purchased

Tags: Discounts, Marketing, Products, Retention

This task watches for newly-paid orders, and if the configured product is purchased, sends the customer a discount code that's just for them. Optionally, configure the discounts to only apply to a certain collection of products, and to only last for a certain number of days.

Default options

{
  "required_product_id__number_required": null,
  "discount_collection_id__number": null,
  "discount_code_prefix": null,
  "discount_fixed_amount__number": null,
  "discount_percentage__number": "50",
  "discount_applies_to_each_line_item_individually__boolean": true,
  "discount_lifetime_in_days__number": "365",
  "email_subject__required": "Thanks for your purchase! Your discount code is DISCOUNT_CODE.",
  "email_body__multiline_required": "Thanks for your purchase! Here's your discount code: <b>DISCOUNT_CODE</b>\n\n<a href=\"https://{{ shop.domain }}/\">Start shopping now!</a>\n\nThanks,\n{{ shop.name }}",
  "discount_can_be_used_by_anyone__boolean": null
}

Learn about task options in Mechanic

Subscriptions

shopify/orders/paid
mechanic/actions/perform

Learn about event subscriptions in Mechanic

Documentation

This task watches for newly-paid orders, and if the configured product is purchased, sends the customer a discount code that's just for them. Optionally, configure the discounts to only apply to a certain collection of products, and to only last for a certain number of days.

If a customer purchases more than one qualified product, they will receive more than one email, each containing a unique discount code.

Options

  • Required product ID: The ID of the product that the customer must purchase, in order to qualify for the discount. (Learn how to find the product ID.)
  • Discount collection ID (optional): The ID of a specific collection of products that the discount code should be good for. (Learn how to find the collection ID.)
  • Discount code prefix (optional): A small piece of text to add to the beginning of the generated discount code.
  • Discount fixed amount: The money value to be subtracted. If you choose this option, you cannot choose a discount percentage.
  • Discount percentage: The percentage to be subtracted (e.g. 15). If you choose this option, you cannot choose a fixed discount amount.
  • Discount applies to each line item individually: If enabled and if a collection ID is configured, the discount will apply to each item from the collection on the order. If disabled, the discount will only apply once per order. If no collection ID is configured, this setting will be overridden to apply once oer order.
  • Discount lifetime in days: How long the discount should be active.
  • Discount can be used by anyone: If enabled, the discount code can be used by anyone. If disabled, the discount code can only be used by the purchasing customer.
  • Email subject, body: The content to email to the customer. Use "DISCOUNT_CODE" as a placeholder for the generated discount code.

Installing this task

Find this task in the library at tasks.mechanic.dev, and use the "Try this task" button. Or, import this task's JSON export – see Importing and exporting tasks to learn how imports work.

Contributions

Found a bug? Got an improvement to add? Start here: ../../CONTRIBUTING.md.

Task requests

Submit your task requests for consideration by the Mechanic community, and they may be chosen for development and inclusion in the task library!