Prevent WooCommerce Orders from being cloned?

Is there a way to prevent cloner from cloning our woocommerce orders?

  • Adam Czajczyk

    Hello Web Developer,

    I hope you're well today and thank you for your question!

    This can be achieved with an additional bit of a code. WooCommerce orders are posts of custom type and Cloner includes a filter hook that we can use to skip "shop_order" type posts:

    <?php 
    
    function wpmu_skip_wc_orders_clonning($args) {
    	if ($args['post_type'] == "shop_order") {
    		$args['posts_per_page'] = 0;
    		return $args;
    	}
    }
    add_filter('wpmudev_copier_get_source_posts_args','wpmu_skip_wc_orders_clonning');

    To apply it to your site please:

    - create an empty file with .php extension (e.g. "skip-wc-orders-cloning.php")
    - paste that code inside using "clean text" editor (like Notepad++, Sublime or similar)
    - upload the file to the "/wp-content/mu-plugins" folder of your Multisite.

    If there's no "mu-plugins" folder inside "wp-content" folder, create it.

    I tested it on my Multisite test setup and it seems to be working fine.

    I hope that helps :slight_smile:

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.