/**
  * Schedule all orders for a payment plan.
  * This is important because the tax point is when the order is placed.
  * @param  WC_Deposits_Plan $payment_plan
  * @param  int $original_order_id
  */
 public static function schedule_orders_for_plan($payment_plan, $original_order_id, $item)
 {
     $schedule = $payment_plan->get_schedule();
     $current_timestamp = current_time('timestamp');
     $payment_number = 2;
     $line_price = self::_get_normalized_price_before_plan($payment_plan, $item);
     $plan_type = $payment_plan->get_type();
     // Track the amount of each payment (start with deposit)
     $previous_payments = $schedule[0]->amount;
     // Skip first payment - that was taken already
     array_shift($schedule);
     foreach ($schedule as $schedule_row) {
         // Work out relative timestamp
         $current_timestamp = strtotime("+{$schedule_row->interval_amount} {$schedule_row->interval_unit}", $current_timestamp);
         // Work out how much the payment will be for
         if ('fixed' === $plan_type) {
             if ('remainder' === $schedule_row->amount) {
                 $item['amount'] = $line_price - $previous_payments;
             } else {
                 $item['amount'] = $schedule_row->amount;
             }
         } else {
             $item['amount'] = $line_price / 100 * $schedule_row->amount;
         }
         $item = apply_filters('woocommerce_deposits_before_schedule_plan_order', $item, $schedule_row, $payment_plan, $original_order_id);
         $previous_payments += $item['amount'];
         // Create order
         WC_Deposits_Order_Manager::create_order($current_timestamp, $original_order_id, $payment_number, $item, 'scheduled-payment');
         $payment_number++;
     }
 }
 /**
  * Get the class instance
  */
 public static function get_instance()
 {
     return null === self::$instance ? self::$instance = new self() : self::$instance;
 }