Created
December 18, 2014 05:25
-
-
Save kloon/3e9df9445f4940952f17 to your computer and use it in GitHub Desktop.
WC 2.2 Order Status Updates
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
/* 1. Update Pending Orders */ | |
UPDATE wp_posts as posts | |
LEFT JOIN wp_term_relationships AS rel ON posts.ID = rel.object_ID | |
LEFT JOIN wp_term_taxonomy AS tax USING( term_taxonomy_id ) | |
LEFT JOIN wp_terms AS term USING( term_id ) | |
SET posts.post_status = 'wc-pending' | |
WHERE posts.post_type = 'shop_order' | |
AND posts.post_status = 'publish' | |
AND tax.taxonomy = 'shop_order_status' | |
AND term.slug LIKE 'pending%'; | |
/* 2. Update Processing Orders */ | |
UPDATE wp_posts as posts | |
LEFT JOIN wp_term_relationships AS rel ON posts.ID = rel.object_ID | |
LEFT JOIN wp_term_taxonomy AS tax USING( term_taxonomy_id ) | |
LEFT JOIN wp_terms AS term USING( term_id ) | |
SET posts.post_status = 'wc-processing' | |
WHERE posts.post_type = 'shop_order' | |
AND posts.post_status = 'publish' | |
AND tax.taxonomy = 'shop_order_status' | |
AND term.slug LIKE 'processing%'; | |
/* 3. Update On-Hold Orders */ | |
UPDATE wp_posts as posts | |
LEFT JOIN wp_term_relationships AS rel ON posts.ID = rel.object_ID | |
LEFT JOIN wp_term_taxonomy AS tax USING( term_taxonomy_id ) | |
LEFT JOIN wp_terms AS term USING( term_id ) | |
SET posts.post_status = 'wc-on-hold' | |
WHERE posts.post_type = 'shop_order' | |
AND posts.post_status = 'publish' | |
AND tax.taxonomy = 'shop_order_status' | |
AND term.slug LIKE 'on-hold%'; | |
/* 4. Update Completed Orders */ | |
UPDATE wp_posts as posts | |
LEFT JOIN wp_term_relationships AS rel ON posts.ID = rel.object_ID | |
LEFT JOIN wp_term_taxonomy AS tax USING( term_taxonomy_id ) | |
LEFT JOIN wp_terms AS term USING( term_id ) | |
SET posts.post_status = 'wc-completed' | |
WHERE posts.post_type = 'shop_order' | |
AND posts.post_status = 'publish' | |
AND tax.taxonomy = 'shop_order_status' | |
AND term.slug LIKE 'completed%'; | |
/* 5. Update Cancelled Orders */ | |
UPDATE wp_posts as posts | |
LEFT JOIN wp_term_relationships AS rel ON posts.ID = rel.object_ID | |
LEFT JOIN wp_term_taxonomy AS tax USING( term_taxonomy_id ) | |
LEFT JOIN wp_terms AS term USING( term_id ) | |
SET posts.post_status = 'wc-cancelled' | |
WHERE posts.post_type = 'shop_order' | |
AND posts.post_status = 'publish' | |
AND tax.taxonomy = 'shop_order_status' | |
AND term.slug LIKE 'cancelled%'; | |
/* 6. Update Refunded Orders */ | |
UPDATE wp_posts as posts | |
LEFT JOIN wp_term_relationships AS rel ON posts.ID = rel.object_ID | |
LEFT JOIN wp_term_taxonomy AS tax USING( term_taxonomy_id ) | |
LEFT JOIN wp_terms AS term USING( term_id ) | |
SET posts.post_status = 'wc-refunded' | |
WHERE posts.post_type = 'shop_order' | |
AND posts.post_status = 'publish' | |
AND tax.taxonomy = 'shop_order_status' | |
AND term.slug LIKE 'refunded%'; | |
/* 7. Update Failed Orders */ | |
UPDATE wp_posts as posts | |
LEFT JOIN wp_term_relationships AS rel ON posts.ID = rel.object_ID | |
LEFT JOIN wp_term_taxonomy AS tax USING( term_taxonomy_id ) | |
LEFT JOIN wp_terms AS term USING( term_id ) | |
SET posts.post_status = 'wc-failed' | |
WHERE posts.post_type = 'shop_order' | |
AND posts.post_status = 'publish' | |
AND tax.taxonomy = 'shop_order_status' | |
AND term.slug LIKE 'failed%'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment