Update to woocommerce 2.2 and:
<?php
/**
* Create custom order
**/
function create_custom_order($orderid) {
$origin_order = new WC_Order($orderid);
//create order args
$args = array(
'status' => 'on-hold',
);
//order address
$address = array(
'first_name' => $origin_order->billing_first_name,
'email' => $origin_order->billing_email,
'phone' => $origin_order->billing_phone,
'address_1' => $origin_order->billing_address_1,
'city' => $origin_order->billing_city,
'state' => $origin_order->billing_state,
'postcode' => $origin_order->billing_postcode,
'country' => 'BR'
);
//plan by user
$plan = $origin_order->billing_plano;
//order date
$origin_date = $origin_order->post->post_date;
//create order repeater
for ($i=0; $i < $plan; $i++) {
//create new order
$order = wc_create_order($args);
//new date
$new_date = date('Y-m-d H:i:s',strtotime($origin_date . '+'. $i .' months'));
$custom_date = array(
'ID' => $order->id,
'post_date' => $new_date
);
//get items origin order
$orderitems = $origin_order->get_items();
//new order add products
foreach ($orderitems as $item ) {
$productitem = apply_filters( 'woocommerce_order_item_product', $origin_order->get_product_from_item( $item ), $item );
$idproduct = $productitem->parent->id;
$order->add_product( get_product( ''.$idproduct.'' ), $item['qty'] );
}
//update new order address
$order->set_address( $address, 'billing' );
//update new order shipping
$order->calculate_shipping();
//update new order totals
$order->calculate_totals();
//update new order date
wp_update_post($custom_date);
}
}
?>