Sources:
- https://www.taniarascia.com/how-to-create-and-use-bash-scripts/
- https://www.presslabs.com/code/wp-cli-guide-wp-term/
- https://stackoverflow.com/questions/59084630/wp-cli-wc-product-create-custom-attributes
My recipes:
# Check themes, core, plugins for updates alias check-all='wp core check-update && wp plugin list --update=available && wp theme list --update=available' # Update all that it can be updated alias update-all='wp core update && wp plugin update --all && wp theme update --all' # Get all product ids OF category 53wp wc product list --category=53 --user=2 --field=id
# Update the category of product with id 374 to 33wp wc product update 374 --categories='[{"id":33}]' --user=2
# Move products to another category. You have to add the current category otherwise it does not work. !/usr/bin/bash for post in $(wp wc product list --category=54 --user=2 --field=id) do wp wc product update $post --categories='[{"id":52},{"id":54}]' --user=2 done # Add these attributes to the products of this category !/bin/bash for post in $(wp wc product list --category=57 --user=2 --format=ids) do wp wc product update $post --user=2 --attributes='[{"id":1,"name":"Color","position":0, "visible":true,"options":["Blue","Red"]}]'; done