/**
  * Generate an order to record a subscription payment. 
  *
  * This function is hooked to the scheduled subscription payment hook to create a pending
  * order for each scheduled subscription payment.
  *
  * When a payment gateway calls the @see WC_Subscriptions_Manager::process_subscription_payment()
  * @see WC_Order::payment_complete() will be called for the renewal order.
  *
  * @param $user_id int The id of the user who purchased the subscription
  * @param $subscription_key string A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
  * @since 1.2
  */
 public static function maybe_generate_manual_renewal_order($user_id, $subscription_key)
 {
     if (WC_Subscriptions_Manager::requires_manual_renewal($subscription_key, $user_id)) {
         $subscription = WC_Subscriptions_Manager::get_users_subscription($user_id, $subscription_key);
         self::generate_renewal_order($subscription['order_id'], $subscription['product_id'], 'child');
     }
 }
 /**
  * Generate an order to record a subscription payment.
  *
  * This function is hooked to the scheduled subscription payment hook to create a pending
  * order for each scheduled subscription payment.
  *
  * When a payment gateway calls the @see WC_Subscriptions_Manager::process_subscription_payment()
  * @see WC_Order::payment_complete() will be called for the renewal order.
  *
  * @param int $user_id The id of the user who purchased the subscription
  * @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
  * @since 1.2
  */
 public static function maybe_generate_manual_renewal_order($user_id, $subscription_key)
 {
     if (WC_Subscriptions_Manager::requires_manual_renewal($subscription_key, $user_id)) {
         $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key);
         $renewal_order_id = self::generate_renewal_order($subscription['order_id'], $subscription['product_id'], array('new_order_role' => 'child'));
         do_action('woocommerce_generated_manual_renewal_order', $renewal_order_id);
     }
 }
 /**
  * Generate an order to record a subscription payment.
  *
  * This function is hooked to the scheduled subscription payment hook to create a pending
  * order for each scheduled subscription payment.
  *
  * When a payment gateway calls the @see WC_Subscriptions_Manager::process_subscription_payment()
  * @see WC_Order::payment_complete() will be called for the renewal order.
  *
  * @param int $user_id The id of the user who purchased the subscription
  * @param string $subscription_key A subscription key of the form created by @see WC_Subscriptions_Manager::get_subscription_key()
  * @since 1.2
  */
 public static function maybe_generate_manual_renewal_order($user_id, $subscription_key)
 {
     if (WC_Subscriptions_Manager::requires_manual_renewal($subscription_key, $user_id)) {
         $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key);
         // $0 renewals don't require a pending renewal order, instead a paid renewal order will be created by WC_Subscriptions_Manager::maybe_process_subscription_payment()
         if (WC_Subscriptions_Order::get_recurring_total($subscription['order_id']) > 0) {
             $renewal_order_id = self::generate_renewal_order($subscription['order_id'], $subscription['product_id'], array('new_order_role' => 'child'));
             do_action('woocommerce_generated_manual_renewal_order', $renewal_order_id);
         }
     }
 }