I have a sales page with a time-sensitive offer on one of my wordpress posts. The idea is that the first person that comes to the page and buys first gets the product.
Therefore when charge succeeded event in Stripe (payment processor) is triggered, I want the sales page to be redirected to a "sorry it is too late" page. I am using the gravity forms + stripe plugin.
So for example, I have a page called sales page. It is available for 3 days.
1 day into the sale someone comes along and buys the product.
If someone else comes to the sales page after the product has been purchased, I want it to go to a too late page.
Here is the code I have created. test key in the code is fake for posting purposes. I think I am missing some wordpress hook in my code.
I use a value in custom field suite plugin meta box on the post as the too late trigger.
When the value is set to 1, the page disappears.
When it is zero, the page is available and the product can still be purchased.
The problem is I am not sure where to put the code. Because when I add it to my theme's functions.php it says fatal error called to undefined function add_action()