autoship_create_scheduled_orders_on_checkout (function)

(src/orders.php) Wrapper function for Scheduled Orders created at checkout only. It takes the WooCommerce Order Object or Id ($order_id) and the (optional) date the Scheduled Order should be created ($creation_date) as its parameters. 

Function

 
(src/orders.php) /**
* Wrapper for creating scheduled orders at checkout only.
* @uses autoship_create_scheduled_orders()
*
* @param WC_Order|int $order A WC Order object or order id.
* @param string       Optional. $creation_date The date the order should be
*                     created based on should be 'Y-m-d H:i:s' format.
*                     Default NULL.
* @return void
*/
function autoship_create_scheduled_orders_on_checkout ( $order_id, $creation_date = null ) {

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

  // Check if this is a checkout order
  // QPilot to update the status only vs. run payment_complete.
  $created_via = $order->get_created_via();
  if ( ( ! $order ) || ( $created_via != 'checkout' ) ) {
    // This is not a checkout order
    return;
  }

  $scheduled_order_ids = autoship_create_scheduled_orders( $order_id, $creation_date );

  do_action( 'autoship_post_create_scheduled_orders_on_checkout', $scheduled_order_ids, $order_id );

}