Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 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%';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement