Ah, got you! Functions can’t read previous customer orders, but they can read customer tags. A potential workaround would be to tag customers who meet your criteria (with a script, manually or maybe Flow could help?), and then the function could look for that tag to apply the discount.