• Building an integration with a 3rd party API which is posting to the URL http://www.mysite.com/subfolderinstall/wc-api/update_order/
    Have the below code which isn’t working but I think demonstrates what I’m attempting to do. Wondering if the subfolder install is having an effect? May well just be poorly formed code. The order has the custom field external_order_id which is being added fine.
    Any pointers gratefully received!

    add_action( 'woocommerce_api_update_order', 'update_order_handler' );
    
    function pwinty_update_order_handler() {
          $externalOrderId = $_POST["orderId"];
    	  $event_status = $_POST["eventData"];
    	  $args = array(
    	  'numberposts' => 1,
    	  'meta_key' => 'external_order_id',
    	  'meta_value' => $externalOrderId
                          );
          $query = new WP_Query( $args );
    	  if( $query->have_posts() ):  while ( $query->have_posts() ) : $query->the_post();
    	  $wooOrderId = get_the_ID();
    	  $order = new WC_Order($wooOrderId);
              $order->add_order_note($event_status);
    	  endwhile;
    	  endif;
    	  wp_reset_query();
    
    }

The topic ‘Woocommerce – Add order note via API callback’ is closed to new replies.