Blog

2 easy ways to clone/duplicate customer orders in WooCommerce

duplicate customer orders
Table of Contents

WooCommerce clone order is a feature that allows store managers to create a copy of one or more orders registered on the site as a new order. This means that all the values of the previous order are exactly repeated in the duplicated order, and the site manager only has to change the minor information, such as the date of the order if needed.

By duplicating customer orders in WooCommerce instead of creating a new order and entering the values of all order fields such as billing address, shipping address, etc., site owners can save their time and effort.

In the default options of WooCommerce, it is not possible to clone many customer orders at once, but you must open each order page individually. This is why most site owners need to use the duplicate customer order plugin in WooCommerce.

In this post, we will first show you how to do WooCommerce duplicate orders through coding, and then we will introduce you to the bulk edit orders plugin, with the help of which you can clone customer orders with one click.

woocommerce duplicate order programmatically

Php codes are one of the useful methods for customizing WordPress websites. However, if you need to become more familiar with coding, it makes sense to get help from an expert to add any code to your website. We also recommend you back up your site before adding a custom code snippet to copy/duplicate WooCommerce orders. 

If you take all reasonable precautions to prevent potential damages, use the following code for WooCommerce clone order:

function ithemeland_duplicate_order( $original_order_id ) {

    // Load Original Order
    $original_order = wc_get_order( $original_order_id );
    $user_id = $original_order->get_user_id();

    // Setup Cart
    WC()->frontend_includes();
    WC()->session = new WC_Session_Handler();
    WC()->session->init();
    WC()->customer = new WC_Customer( $user_id, true );
    WC()->cart = new WC_Cart();

    // Setup New Order
    $checkout = WC()->checkout();
    WC()->cart->calculate_totals();
    $order_id = $checkout->create_order( [ ] );
    $order = wc_get_order( $order_id );
    update_post_meta( $order_id, '_customer_user', get_current_user_id() );

    // Header
    update_post_meta( $order_id, '_order_shipping', get_post_meta($original_order_id, '_order_shipping', true) );
    update_post_meta( $order_id, '_order_discount', get_post_meta($original_order_id, '_order_discount', true) );
    update_post_meta( $order_id, '_cart_discount', get_post_meta($original_order_id, '_cart_discount', true) );
    update_post_meta( $order_id, '_order_tax', get_post_meta($original_order_id, '_order_tax', true) );
    update_post_meta( $order_id, '_order_shipping_tax', get_post_meta($original_order_id, '_order_shipping_tax', true) );
    update_post_meta( $order_id, '_order_total', get_post_meta($original_order_id, '_order_total', true) );
    update_post_meta( $order_id, '_order_key', 'wc_' . apply_filters('WooCommerce_generate_order_key', uniqid( 'order_' ) ) );
    update_post_meta( $order_id, '_customer_user',get_post_meta($original_order_id, '_customer_user', true) );
         
    update_post_meta( $order_id, '_order_currency', get_post_meta($original_order_id, '_order_currency', true) );
    update_post_meta( $order_id, '_prices_include_tax', get_post_meta($original_order_id, '_prices_include_tax', true) );
    update_post_meta( $order_id, '_customer_ip_address', get_post_meta($original_order_id, '_customer_ip_address', true) );
    update_post_meta( $order_id, '_customer_user_agent', get_post_meta($original_order_id, '_customer_user_agent', true) );

    // Billing
    update_post_meta( $order_id, '_billing_city', get_post_meta($original_order_id, '_billing_city', true));
    update_post_meta( $order_id, '_billing_state', get_post_meta($original_order_id, '_billing_state', true));
    update_post_meta( $order_id, '_billing_postcode', get_post_meta($original_order_id, '_billing_postcode', true));
    update_post_meta( $order_id, '_billing_email', get_post_meta($original_order_id, '_billing_email', true));
    update_post_meta( $order_id, '_billing_phone', get_post_meta($original_order_id, '_billing_phone', true));
    update_post_meta( $order_id, '_billing_address_1', get_post_meta($original_order_id, '_billing_address_1', true));
    update_post_meta( $order_id, '_billing_address_2', get_post_meta($original_order_id, '_billing_address_2', true));
    update_post_meta( $order_id, '_billing_country', get_post_meta($original_order_id, '_billing_country', true));
    update_post_meta( $order_id, '_billing_first_name', get_post_meta($original_order_id, '_billing_first_name', true));
    update_post_meta( $order_id, '_billing_last_name', get_post_meta($original_order_id, '_billing_last_name', true));
    update_post_meta( $order_id, '_billing_company', get_post_meta($original_order_id, '_billing_company', true));

    // Shipping
    update_post_meta( $order_id, '_shipping_country', get_post_meta($original_order_id, '_shipping_country', true));
    update_post_meta( $order_id, '_shipping_first_name', get_post_meta($original_order_id,  '_shipping_first_name', true));
    update_post_meta( $order_id, '_shipping_last_name', get_post_meta($original_order_id, '_shipping_last_name', true));
    update_post_meta( $order_id, '_shipping_company', get_post_meta($original_order_id, '_shipping_company', true));
    update_post_meta( $order_id, '_shipping_address_1', get_post_meta($original_order_id, '_shipping_address_1', true));
    update_post_meta( $order_id, '_shipping_address_2', get_post_meta($original_order_id, '_shipping_address_2', true));
    update_post_meta( $order_id, '_shipping_city', get_post_meta($original_order_id, '_shipping_city', true));
    update_post_meta( $order_id, '_shipping_state', get_post_meta($original_order_id, '_shipping_state', true));
    update_post_meta( $order_id, '_shipping_postcode', get_post_meta($original_order_id, '_shipping_postcode', true));

// Shipping Items
   $original_order_shipping_items = $original_order->get_items( 'shipping' );
foreach ( $original_order_shipping_items as $original_order_shipping_item ) {
    $item_id = wc_add_order_item( $order_id, array(
    'order_item_name' => $original_order_shipping_item['name'],
    'order_item_type' => 'shipping'
    ) );
    if ( $item_id ) {
        wc_add_order_item_meta( $item_id, 'cost', wc_format_decimal( $original_order_shipping_item['cost'] ) );
    }
}

// Coupons
$original_order_coupons = $original_order->get_items( 'coupon' );
foreach ( $original_order_coupons as $original_order_coupon ) {
    $item_id = wc_add_order_item( $order_id, array(
    'order_item_name' => $original_order_coupon['name'],
    'order_item_type' => 'coupon'
    ) );
   if ( $item_id ) {
       wc_add_order_item_meta( $item_id, 'discount_amount', $original_order_coupon['discount_amount'] );
   }
}

// Payment
update_post_meta( $order_id, '_payment_method', get_post_meta( $original_order_id, '_payment_method', true ) );
update_post_meta( $order_id, '_payment_method_title', get_post_meta( $original_order_id, '_payment_method_title', true ) );
update_post_meta( $order_id, 'Transaction ID', get_post_meta( $original_order_id, 'Transaction ID', true ) );

// Line Items
foreach( $original_order->get_items() as $originalOrderItem ) {
    $itemName = $originalOrderItem['name'];
    $qty = $originalOrderItem['qty'];
    $lineTotal = $originalOrderItem['line_total'];
    $lineTax = $originalOrderItem['line_tax'];
    $productID = $originalOrderItem['product_id'];
    $item_id = wc_add_order_item( $order_id, array(
    'order_item_name' => $itemName,
    'order_item_type' => 'line_item'
    ) );
    wc_add_order_item_meta( $item_id, '_qty', $qty );
    wc_add_order_item_meta( $item_id, '_tax_class', $originalOrderItem['tax_class'] );
    wc_add_order_item_meta( $item_id, '_product_id', $productID );
    wc_add_order_item_meta( $item_id, '_variation_id', $originalOrderItem['variation_id'] );
    wc_add_order_item_meta( $item_id, '_line_subtotal', wc_format_decimal( $lineTotal ) );
    wc_add_order_item_meta( $item_id, '_line_total', wc_format_decimal( $lineTotal ) );
    wc_add_order_item_meta( $item_id, '_line_tax', wc_format_decimal( $lineTax ) );
    wc_add_order_item_meta( $item_id, '_line_subtotal_tax', wc_format_decimal( $originalOrderItem['line_subtotal_tax'] ) );
}

// Close New Order
$order->calculate_totals();
$order->payment_complete();
// Note
$order->update_status( 'processing' );
$message = sprintf(
'This order was duplicated from order %d.',
$original_order_id
);
$order->add_order_note( $message );

// Return
return $order_id;
}

To run this code on your WordPress website, it is better to install the Code Snippets plugin and then go to the address below:

WP Admin > Snippets > Add New

Now, copy the code mentioned above and paste it into the website.

When you customize the code as you need and choose where to show the result – back end or front end, press the “Save and Activate” button.

By running this code, you can write the ID of any order in your online store to duplicate it.

Despite the fact that you need to have special skills to use the PHP codes, the time and effort spent to write and add a code to the website is not worth it. For example, there is no option for finding and filtering the orders you want to duplicate in this code. So, you have to add many code lines to customize it for your purpose.

If you are looking for a straightforward way to duplicate orders in WooCommerce, your ultimate solution is the WooCommerce bulk edit orders plugin. To learn how this duplicate customer order plugin can simplify the process of cloning orders, continue reading.

Use the orders bulk edit plugin for WooCommerce duplicate orders

The WooCommerce orders bulk edit plugin comes with a lot of amazing features for bulk editing, bulk removing, or duplicating WooCommerce orders. The powerful Filter Form designed for this plugin enables you to find and filter the desired orders quickly. Another useful tool provided in this plugin is a specific button helping store managers clone customer orders of WooCommerce with one click.

Let’s see how this plugin makes copying multiple WooCommerce orders at once easier.

1. Download and install the plugin

The first step to use the orders bulk edit plugin is to download and install it. After installing and activating your WordPress website, this plugin adds a new item to your WordPress dashboard called iT Bulk Editing.

WooCommerce order bulk edit

If you press Woo orders from this new tab, you will be led to the main page of the plugin.

select woo orders menu in bulk edit plugin WooCommerce

On this page, there is a list of all orders in a table with a comprehensive toolbar on top of it. The items available in the toolbar have many functions, allowing you to manage the orders on your WooCommerce store easily. However, to fulfill the purpose of this tutorial, you just need to use the Filter Form and Duplicate buttons from the toolbar.

toolbar menu in bulk edit orders plugin
duplicate order woocommerce

Read more to find out how to clone/duplicate customer orders in WooCommerce with these tools.

2. Filter the desired orders

The first icon in the toolbar of the WooCommerce orders bulk edit plugin is Filter. By pressing the icon, you have access to a comprehensive Filter Form supported by all fields of WooCommerce orders as well as custom fields. 

To help you find the WooCommerce fields faster, the Filter Form is divided into seven tabs, including:

  • General
  • Billing
  • Shipping 
  • Pricing 
  • Items
  • Other Fields
  • Custom Fields
general tab in filter form bulk edit orders plugin

So, you can find the right field(s) for filtering just with a quick look and limit the orders for duplicating by pressing Get Orders.

For example, if you want to filter the orders based on the billing last name of your customers and then clone customer orders in WooCommerce, follow the below instructions:

  1. Open Filter Form and go to the Billing tab.
  2. Find the Billing Last Name field, open the first dropdown list, and choose Exact.
  3. Write the last name of your customer in the following box -Smith in this example.
  4. Press the Get Orders button.
select smith option in billing last name field bulk edit orders plugin

Now, you can see a list of all orders placed with Smith in the order table. 

2. Select desired orders and clone customer orders WooCommerce

After filtering your desired orders, to use the WooCommerce duplicate orders tool in the plugin, follow the below instructions:

  1. Select some or all filtered orders in the table.
  2. Click on the Duplicate Orders button.
mark all ID and select duplicate button in orders WooCommerce
  1. In the pop-up page that appears on the screen, set how many times you want to copy WooCommerce orders. It is possible to either write a number manually or increase/decrease it by up/down arrows.
  2. Press the Start Duplicate button.
select three item to duplicate in orders WooCommerce

That’s it. The plugin will automatically create the new orders and copy all information of the selected orders to them.

4. Inline edit the new orders

The WooCommerce bulk edit orders plugin has many useful features allowing you to inline edit or bulk edit any features of the new orders. For example, if you want to edit the status of new orders, you can easily:

  • Open the Column Profile Form.
  • Mark the Status field to be displayed in the table.
column profile tab in orders WooCommerce
woocommerce double orders
  • Open the Status field in the table and select one of the order statuses from the list.
select completed option in status column in orders WooCommerce

Use export/import to duplicate orders in WooCommerce

The export/import method is another useful technique for WooCommerce duplicate orders. The default option of WordPress cannot filter orders and export them. So, it may not be so practical when you want to duplicate orders WooCommerce with specific features. Our plugin solves this problem by offering a flexible filtering tool and exporting the selected orders to CSV. To access the duplicated orders on your website, you can import the CSV file into WordPress again.

You can find a step-by-step guide for how to duplicate orders in WooCommerce by import/export here

1. Filter WooCommerce orders and select desired orders

Like other techniques, the first step for WooCommerce double orders is filtering. We have reviewed the options available in the Filter Form of the WooCommerce bulk orders editing plugin in the previous method. Getting help from this form, you can easily find and filter your preferred orders and display them in the table.

Then to use the Import/Export tool in our plugin, select all or some of the orders in the table as shown below:

Filter WooCommerce orders and select desired orders
duplicate orders

2. Export WooCommerce orders to CSV

After selecting some orders, press Import/Export tool in the toolbar to open the form:

Select export icon in orders bulk edit plugin toolbar

In this form, you can use one of the following options to export orders for duplication: 

  • All orders in the table with all fields 
  • All orders in the table with only visible fields 
  • Only selected orders with all fields
  • Only selected orders with only visible fields
customize export section orders in WooCommerce orders bulk edit plugin

If you want to use the Only Visible Fields option, it makes sense to customize the order table columns based on your needs. To make this happen, you can simply open the Column Manager form, mark the Order Fields that you want to show in the Order Table, and export them.

customize column profiles form in WooCommerce orders bulk edit plugin

3. WooCommerce clone order in Excel or Google sheet

As soon as pressing the Export Now button, a CSV file will be downloaded and saved on your system. Then, you need to open this file in Excel or Google sheet and follow the below instructions to duplicate the order WooCommerce:

  • Select the orders you want to duplicate.
  • Right click on the orders and choose Copy for WooCommerce copy order.
Orders copy result in Excel file
woocommerce clone order
  • Right click on one empty cell and choose the Paste option.
  • Save the CSV file.

You can repeat these steps to duplicate WooCommerce orders multiple times.

Orders Paste result in Excel file

4. Import WooCommerce orders 

Finally, you can open the Import/Export form in the WooCommerce orders bulk edit plugin again. Then choose the Import option to add the duplicated orders to your website from the CSV file.

Here, you can find more details about how to Import/Export WooCommerce orders.

Benefits WooCommerce orders bulk editing plugin

The WooCommerce orders bulk edit plugin comes with a simple-to-use interface allowing you to have full control over the WooCommerce orders. In addition, we have a growing number of tutorials to guide you on using different tools and options available in this plugin for duplicating, managing, or bulk editing WooCommerce orders.

The useful tools designed in this plugin reduce the time needed for order management in your store allowing you to focus on other aspects of your business. You don’t have to spend lots of hours searching, editing, or duplicating orders. All of these are possible with a few clicks in this plugin.

Moreover, it has unique features over other WooCommerce orders management and duplicator plugins, including:

An advanced filter form to find desired WooCommerce orders 

The WooCommerce orders bulk editing plugin allows you to do advanced searches and apply multiple filters to find WooCommerce orders in seconds. It’s located on the plugin’s toolbar, so you can open it with one click and have access to all order fields to find any order before duplicate.

Duplicate multiple WooCommerce orders with one click

You can duplicate, clone, and copy multiple orders at once. The plugin has no limitation on the number of orders selected for duplication. So, you can enjoy marking as many orders as you need in the table and duplicating them with a single click.

Duplicate a WooCommerce order multiple times

If you need to copy one WooCommerce order multiple times, the plugin supports you. Simply, select the order and use the duplicate tool to clone the order as many times as you need.

Bulk edit WooCommerce orders 

The bulk edit tool in the toolbar, allows you to bulk change any WooCommerce order field in a second. It can make the tedious task of editing order fields after duplicating very simple. With the help of a bulk edit form, you can save time and reduce errors associated with manual WooCommerce order editing.

WooCommerce order bulk edit

Why do you need to duplicate customer orders in WooCommerce?

When you have a small store, and the number of your orders is limited, creating a duplicate order with WooCommerce will not cause you many problems. But as your store grows, the number of duplicate orders increases, and creating similar orders with most of the same information becomes a long and tedious process.

In this situation, you should use the clone customer order method in WooCommerce to register duplicate orders that have the same details from the same customers. That way, you don’t have to enter duplicate information over and over again every time you place an order. The other reasons for using WooCommerce duplicate order methods are to save time and prevent any mistakes when copying the order information.

Unfortunately, the default options in WooCommerce do not let you filter and duplicate multiple orders at once. So, you may need to use a duplicate customer order plugin to do this task easily and quickly.

Conclusion

If your store has many loyal customers who regularly order the same products from your store, placing repeat orders with the same details from the same customers will be a time-consuming process. To save your time and effort, you need to use the duplicate customer order plugin in WooCommerce. In this post, we introduced you to the WooCommerce orders bulk edit plugin so that you can duplicate WooCommerce orders in a few seconds with its practical tools.

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign in

No account yet?

We use cookies to improve your experience on our website. By browsing this website, you agree to our use of cookies.

4.7
Based on 497 reviews
5 star
69
69%
4 star
30
30%
3 star
1
1%
2 star
0
0%
1 star
0
0%
1-5 of 497 reviews
  1. M

    Best app!

  2. G

    Great support!

  3. V

    I wan to add 500+ variations, I tried 10’s of plugins, but none of the plugin is solving my problem, but Bulk Variation Plugin is helping me with it.

  4. P

    I purchased this plugin to enhance functionality on a client’s website. While I found other plugins, some cheaper or even free, none matched the ease of customization and clean, tailored layout offered by this one. I’m pleased with the responsive support;

  5. S

    Extraordinary service and quality of this plugin! The plugin is very flexible and good, and the support of the developers are extraordinary. They did, free of charge, alter the plugin for me!! A+++++