There are two different kinds of codes:
You can make an automatic discount or a normal discount code. Stick to normal discount codes for the purposes of simplicity and also being sure your affiliates always get the commission for sales they have brought in.
Affiliate discounts or discounts for Facebook ads
These codes you will want to create with no time limit or restrictions.
Click on discounts in your Shopify dashboard menu
Click create discount on the right-hand side
Select discount code
Give your code a cute name or use the code your affiliate selected
Select what kind of discount it is: percentage, fixed amount, free shipping, or buy X get Y
Add the value of the discount
Select the requirements (none if this is for ads or affiliates)
Save discount
24 Hour Affiliate Discounts or Flash Sales
These codes you will want to create with time limits and/or restrictions.
Click on discounts in your Shopify dashboard menu
Click create discount on the right-hand side
Select discount code
Give your code a cute name or use the code your affiliate selected
Select what kind of discount it is: percentage, fixed amount, free shipping, or buy X get Y
Add the value of the discount
Select the requirements (is this code only for certain customers? do they have to have a minimum purchase amount?)
Add 24 hours in the active dates
Save discount