DEV Community

Cover image for How to send promotion emails with Shopify Orders at random, with a Pipedream workflow
Pipedream
Pipedream

Posted on

How to send promotion emails with Shopify Orders at random, with a Pipedream workflow

Discount codes are a great way to build customer loyalty. Even better, adding a layer of chance adds an element of excitement to the order.

In this episode we show you how to generate promotional emails from your Shopify orders without adding any apps to your store.

You can control how chances each order has of triggering a discount code in an email. Or you can remove this random portion altogether for a post-purchase email message.

Here's the random number generator code step you can use in your workflows:

export default defineComponent({
  props: {
    minimum: { type: 'string' },
    maximum: { type: 'string' }
  },
  async run({ steps, $ }) {
    const max = parseInt(this.maximum);
    const min = parseInt(this.minimum);

    return Math.floor(Math.random() * (max - min + 1) + min);
  },
})
Enter fullscreen mode Exit fullscreen mode

Learn more and get connected!

🔨 Start building at https://pipedream.com
📣 Read our blog https://pipedream.com/blog
💬 Join our community https://pipedream.com/community

Top comments (0)