Created
April 15, 2022 14:49
-
-
Save gabriserra/6eae474656e24dc57369f6a7d3a8cdc2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
cd /var/www/wordpress | |
for site in $(wp site list --field=url) | |
do | |
echo "Checking" $site | |
wp wc --url=$site shop_coupon list --user=<your-admin-email> | grep <"coupon-code"> > /dev/null | |
if [ $? == "1" ]; then | |
echo "Not found. Creating ..." | |
wp wc --url=$site shop_coupon create \ | |
--user=<your-admin-email> \ | |
--code=<"coupon-code"> \ | |
--amount=<amount> \ | |
--discount_type="percent" \ | |
--date_expires=<"yyyy-mm-dd"> | |
else | |
echo "Already there!" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment