Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function seifsa_complete_order( $user_id, $tags ) {
- if( in_array( 'Tag Name', $tags ) ) {
- $orders = get_posts( array(
- 'numberposts' => 1,
- 'meta_key' => '_customer_user',
- 'meta_value' => $user_id,
- 'post_type' => wc_get_order_types(),
- 'post_status' => array_keys( wc_get_order_statuses() ),
- 'fields' => 'ids'
- ) );
- if( ! empty( $orders ) ) {
- $order = wc_get_order( $orders[0] );
- $order->update_status( 'completed' );
- wp_fusion()->user->remove_tags( array( 'Tag Name' ), $user_id );
- }
- }
- }
- add_action( 'wpf_tags_modified', 'seifsa_complete_order', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement