Title: [Plugin: Woocommerce] Custom order
Last modified: August 22, 2016

---

# [Plugin: Woocommerce] Custom order

 *  Resolved [lucaspalencia](https://wordpress.org/support/users/lucaspalencia/)
 * (@lucaspalencia)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/plugin-woocommerce-custom-order/)
 * Hi!
    In my checkout, the user can select the date of shipping and the plan (example:
   3 months, 6, 9). For simplify the admin, im thinking to create custorm orders
   and only change the date based on plan that the user selected.
 * In one of my searchs, i saw about `wc_create_order()`, but im using woocommerce
   2.1 and this function not exists.
    Some suggestions / example? The best way is
   update woocommerccec and use wc_create_order ?
 * thanks!

Viewing 1 replies (of 1 total)

 *  Thread Starter [lucaspalencia](https://wordpress.org/support/users/lucaspalencia/)
 * (@lucaspalencia)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/plugin-woocommerce-custom-order/#post-5455317)
 * 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);
           }
       }
   
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Woocommerce] Custom order’ is closed to new replies.

## Tags

 * [wooocommerce](https://wordpress.org/support/topic-tag/wooocommerce/)

 * 1 reply
 * 1 participant
 * Last reply from: [lucaspalencia](https://wordpress.org/support/users/lucaspalencia/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/plugin-woocommerce-custom-order/#post-5455317)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
