Zapier: Creating An Order In Shopify
In this article, we will go through the steps required to automate the reward fulfillment process with your Shopify store. When an Advocate redeems a reward we can use Zapier to create the order in your Shopify store as well as adding the Advocate as a new customer or updating their details if they are an existing customer in your Shopify store which is needed to ensure the Advocate's shipping address is also available to you in your Shopify store. We can also set up two additional Zaps so that rewards in the hub can be automatically fulfilled or refused in the hub depending on when the order was fulfilled or canceled in your Shopify store.
This article will cover:
Creating Your Reward In AdvocateHub
Firstly we want to create the reward in the AdvocateHub. There is a more general article here on the creation of rewards which would be helpful to look at but we do need to include one crucial additional step to our reward creation.
In this example we will use a T-Shirt as our reward. The first tab of the reward Fulfillment should look like below with 'manual' chosen"
The second tab, Headline, can be filled out as you please, this is just the name, description etc. of your reward.
The third tab, Redeeming, is important. At the bottom of this section you should see an Ask Your Advocates section. Here we need to ask the Advocate to fill in their shipping details. You are free to add more questions here but for this example we will stick with the basics:
The final tab is up to you again, this is just for targeting purposes so you are free to target to anybody you like. Save this and we can move on to the next step.
In your Shopify store you will need to create the corresponding product to the reward we just created. You can do this by following the instruction here.
Also in your Shopify store you are going to need to get your API details which we will use later. You can do this by following the instructions here.
Now that we have everything in place we can move on to building our Zap!
Building The 'Create Order' Zap
1. Go to Zapier, and click on Make a Zap!
2. Choose Webhook for the 'App' and select Catch Hook for the 'trigger'. At this point it should look like below:
3. Copy the webhook link present in the View Webhook section and then continue to Test this step and copy the webhook link
4. Now open up a new window/tab and navigate to your AdvocateHub's Webhook configuration page: Settings > System > Webhooks
5. Click on the Add a Webhook button:
6. Here you fill out the name of the webhook, the URL and the format. You also select the event you want this webhook to run on:
- Name - Is not important and you can call it whatever makes most sense for you
- Webhook Provider URL - This is the URL we retrieved from Zapier in point 3 above
- Format - Must be 'Form Post'
- Event - In this case it will be 'Reward Redemption Requested'
7. Now we are ready to test that the webhook is being caught so head back to Zapier and go to the 'Test this step' stage. Click 'OK, I did this' and quickly go back to your hub and redeem the T-Shirt reward in your AdvocateHub. If the webhook is working at this point you will see a screen like below:
8. Now we need to add a filter to our Zap in order to make sure this only runs on our specific reward. To add a filter you need to click the small '+' sign and then select FIlter.
9. Go to the Edit Options. You will see 3 fields on the right-hand side. The first field is the data we want to select for our filter, in this case it is 'Source Name'. We want to have the text match exactly the name of our T-Shirt reward in the AdvocateHub. So, it should look like below:
10. On the Test this step section Zapier will give you an overview of when your Zap will succeed or fail.
11. The final part of the Zap requires us to complete the action on our webhook. We want to select Webhooks here.
12. On the next step Custom Request we need to click 'show less common options'.
This will reveal an option called Custom Request which is the one we want.
13. Click continue to move on to the next Edit Template section. Here we will see a lot of fields that need to be filled. I will explain what information needs to go into which field below. I will ignore fields that do not affect us:
|URL||https://[your shopify store].com/admin/orders.json|
"variant_id": 222222222, //This is the variant ID of your product in Shopify
"first_name": "[Advocate's First Name]", //use Zapier's insert field function
"last_name": "[Advocate's Last Name]", //here to add the Advocate information,
"email": "[Advocate's Email]" //you can find the button in the top right of this 'data' field
"first_name": “[Advocate’s First Name]",
"last_name": “[Advocate’s Last Name]",
"address1": “[Advocate’s Address]",
"address2": “[Advocate’s Redemption ID]",
"city": “[Advocate’s City]",
"province": “[Advocate’s Province/State]",
"country": “[Advocate’s Country]",
"zip": “[Advocate’s ZIP]"
|Basic Auth|| [ Shopify API Key]|[Shopify API Password] //Note the pipe character
// '|' separating these two values
|Headers|| Content-Type: application/json
Authorization: [Insert Shopify Key] It should look something like this Basic MzgyYzkxOWJiYjEyYzUxNjEwNmIwNjkzMDBjODRkNjk6ZjlmYTNjZjY3Zj
Building The 'Fulfillment' Zap
This Zap will automatically notify the Advocate in the AdvocateHub that their reward has been fulfilled once it has been marked as fulfilled in your Shopify store. Let's get started:
1. Repeat Steps 1 & 2 from the Zap above but this time we need to copy the Webhook URL given to us by Zapier into our Shopify store.
2. In your Shopify store go to Settings > Notifications and scroll down to the bottom of the page, here you should see a Webhook section , click 'Create a Webhook'
3. Now we need to setup the webhook with the following data:
- Event - 'Order Fulfillment'
- Format - JSON
- URL - The webhook URL you got from Zapier
Hit save webhook when done.
4. Like before, we need to test that this webhook gets caught. So, head back to Zapier and go to the 'Test this step' stage. Click 'OK, I did this' and quickly go to your Shopify store and mark your T-Shirt order as 'fulfilled'. If the webhook is working at this point you will see a screen that informs you that the test was successful.
5. This time we do not need a filter so we go straight to the 'Action' stage of the Zap. Once again we will be choosing 'Webhook' and 'Custom Request'. Refer back to steps 11 & 12 in the previous section if you have forgotten.
6. Click continue to move on to the next section. Here we will see a lot of fields that need to be filled. I will explain what information needs to go into which field below. I will ignore fields that do not affect us:
|URL|| https://api.influitive/reward_redemptions/[Advocate Address2]/decision/fulfill
Note: We choose [Advocate Address2] here as this is where we stored the Influitive
reward redemption ID when we sent the information to Shopify in our first zap. It is not ideal
and can be slightly confusing but it is the only slot we can use in this setup.
"message": "Your reward has been fulfilled!"
|Headers|| Content-Type: application/json
Authorization: [Influitive API Token]
X_ORG_ID: [Influitive X_ORG_ID]
Building The 'Cancellation' Zap
If you don't have stock or want to cancel and order for whatever reason then this Zap will notify the advocate in AdvocateHub and will give them their points back. It is almost identical to the 'Fulfillment' zap we just did so I will just highlight the differences below:
For Step 3 above, you just need to create another Webhook in Shopify and change the event from Order Fulfillment to Order Cancellation and also include the new Webhook URL you got from Zapier
For Step 6 above, the information is the same except for:
URL needs to be changed from https://api.influitive/reward_redemptions/[Advocate Address2]/decision/fulfill to https://api.influitive/reward_redemptions/[Advocate Address2]/decision/refuse
Data should be updated to:
"message": "Your reward has been cancelled"