Advertisement
verygoodplugins

Untitled

Oct 7th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. function example_wpf_wpe_issue() {
  2.  
  3.     $args = array(
  4.         'numberposts' => - 1,
  5.         'post_type'   => 'shop_order',
  6.         'post_status' => array( 'wc-processing', 'wc-completed' ),
  7.         'fields'      => 'ids',
  8.         'meta_query'  => array(
  9.             array(
  10.                 'key'     => 'wpf_complete',
  11.                 'compare' => 'NOT EXISTS',
  12.             ),
  13.         ),
  14.     );
  15.  
  16.     $orders = get_posts( $args );
  17.  
  18.     // NOTE: the results of this query are being cached
  19.  
  20.     foreach ( $orders as $order_id ) {
  21.  
  22.         $complete = get_post_meta( $order_id, 'wpf_complete', true );
  23.  
  24.         // NOTE: the result of this call to get_post_meta is being cached
  25.  
  26.         if ( ! empty( $complete ) ) {
  27.             return;
  28.         }
  29.  
  30.         //
  31.         // API CALLS TO DRIP ARE SENT HERE
  32.         //
  33.  
  34.         update_post_meta( $order_id, 'wpf_complete', true );
  35.  
  36.         $order = wc_get_order( $order_id );
  37.  
  38.         $order->add_order_note( 'WP Fusion order actions completed.' );
  39.  
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement