autoship_update_scheduled_orders_on_pro​cessing (function)

(src/orders.php) Updates the WooCommerce Order's payment gateway metadata when the Order is updated via QPilot after processing payment. Takes the (WooCommerce) $order as its parameter.

Function

/**
* Updates the order payment gateway meta data when updated via QPilot.
* @uses autoship_create_scheduled_orders()
*
* @param WC_Order|int $order A WC Order object or order id.
*/
function autoship_update_scheduled_orders_on_processing( $order_id ) {

  // Get the wc order
  $order = wc_get_order( $order_id );

  $processing_id  = autoship_get_scheduled_order_processing_id( $order );
  $payment_meta   = autoship_get_scheduled_order_payment_response( $order );
  $payment_object = autoship_get_scheduled_order_payment_method( $order );

  // We only care for QPilot orders that have payment meta
  if ( is_checkout() || empty( $processing_id ) || empty( $payment_meta ) )
  return;

  // Check if there is a payment method associated with it and fire the action
  $payment_method = get_post_meta( $order_id, '_payment_method', true );
  $action = empty( $payment_method )? 'general' : $payment_method;
  do_action('autoship_update_scheduled_orders_on_processing_' . $action . '_gateway', $payment_meta, $order, $payment_object );

}

Still need help? Contact Us Contact Us