Advertisement
verygoodplugins

Untitled

Nov 1st, 2017
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. function seifsa_complete_order( $user_id, $tags ) {
  2.  
  3.     if( in_array( 'Tag Name', $tags ) ) {
  4.  
  5.         $orders = get_posts( array(
  6.             'numberposts' => 1,
  7.             'meta_key'    => '_customer_user',
  8.             'meta_value'  => $user_id,
  9.             'post_type'   => wc_get_order_types(),
  10.             'post_status' => array_keys( wc_get_order_statuses() ),
  11.             'fields'      => 'ids'
  12.         ) );
  13.  
  14.         if( ! empty( $orders ) ) {
  15.             $order = new WC_Order( $orders[0] );
  16.             $order->set_status( 'completed' );
  17.  
  18.             wp_fusion()->user->remove_tags( array( 'Tag Name' ), $user_id );
  19.  
  20.         }
  21.  
  22.     }
  23.  
  24. }
  25.  
  26.  
  27. add_action( 'wpf_tags_modified', 'seifsa_complete_order' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement