DEV Community

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

Posted on

4 3

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

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

đź‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay