Last active
July 24, 2020 12:15
-
-
Save luelista/a21a5a141a2ddfb7a05842aa2db2e538 to your computer and use it in GitHub Desktop.
List and update the download URL of all downloadable files of virtual products in a WooCommerce installation
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
(wp post list --post_type=product_variation --meta_key=_downloadable_files --fields=ID | tail -n +2; | |
wp post list --post_type=product --meta_key=_downloadable_files --fields=ID | tail -n +2) | ( | |
while read ID; do wp post meta get $ID _downloadable_files ; done) |
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
# replaces the host "test.ugb-verlag.de" with "ugb-verlag.de" in all download URLs | |
( | |
wp post list --post_type=product_variation --meta_key=_downloadable_files --fields=ID | tail -n +2; | |
wp post list --post_type=product --meta_key=_downloadable_files --fields=ID | tail -n +2) | ( | |
while read ID; do | |
wp post meta get $ID _downloadable_files --format=json | \ | |
jq '.[].file |= (. | sub("test.ugb-verlag.de"; "ugb-verlag.de"))' | \ | |
wp post meta update $ID _downloadable_files --format=json | |
done) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment