• Rosso Digital

    (@roberthemsing)


    Hi YoOhw Studio Team,

    I’d like to request a small interoperability improvement for the Duplicate action.

    Currently, a duplicated order receives an order note, but there is no structured and documented way for other WooCommerce extensions to identify it as a clone. Order notes are useful for admins, but they are not reliable for automation, exports, reporting, or workflow exclusions.

    Could the plugin set WooCommerce’s native Created Via value when creating a duplicate?

    For example:

    $order->set_created_via( 'wc-order-splitter-duplicate' );

    The exact value is less important than it being stable and documented. This would let extensions and custom integrations identify cloned orders without parsing order notes or adding separate plugin-specific metadata.

    Potential use cases include:

    • Excluding clones from automation workflows (e.g., AutomateWoo) or customer emails.
    • Including or excluding clones in order exports and accounting integrations.
    • Filtering clones in reporting, fulfilment, fraud, subscription, and CRM integrations.
    • Differentiating manually cloned orders from normal checkout, REST API, Store API, and admin-created orders.

    Ideally, the identifier would:

    • Be saved using WooCommerce’s native order APIs, so it works with both legacy order storage and HPOS.
    • Remain on the order after its status changes from draft to pending payment, processing, completed, etc.
    • Apply only to the new cloned order – not the original order.
    • Be documented for third-party developers.

    If practical, it could also be useful to provide a distinct, documented source value for split child orders, such as wc-order-splitter-split.

    As a temporary workaround, I am using a snippet that sets a custom Created Via value after the plugin creates the duplicate, then adds that value as an AutomateWoo rule option. I’m sharing it below as an implementation example, but native support in the plugin would be much cleaner and useful across the wider WooCommerce ecosystem.

    Please note that I am sharing the snippet as an example only, without warranty or support; anyone choosing to use it should assess it for their own site, test it in staging first, and take appropriate backups.

    function rd_mark_yoohw_order_duplicate_on_redirect( $location ) {
    $redirect_parts = wp_parse_url( $location );

    if ( empty( $redirect_parts['query'] ) ) {
    return $location;
    }

    parse_str( $redirect_parts['query'], $redirect_args );

    if ( empty( $redirect_args['wcos_action_tip'] ) || 'duplicate' !== $redirect_args['wcos_action_tip'] ) {
    return $location;
    }

    $order_id = ! empty( $redirect_args['id'] )
    ? absint( $redirect_args['id'] )
    : absint( $redirect_args['post'] ?? 0 );

    if ( ! $order_id || ! current_user_can( 'edit_shop_order', $order_id ) ) {
    return $location;
    }

    $order = wc_get_order( $order_id );

    if (
    ! $order instanceof WC_Order ||
    'checkout-draft' !== $order->get_status( 'edit' ) ||
    'yoohw-order-duplicate' === $order->get_created_via( 'edit' )
    ) {
    return $location;
    }

    $order->set_created_via( 'yoohw-order-duplicate' );
    $order->save();

    return $location;
    }

    add_filter( 'wp_redirect', 'rd_mark_yoohw_order_duplicate_on_redirect' );

    function rd_add_yoohw_order_clone_created_via_choice( $choices, $rule ) {
    if (
    class_exists( '\AutomateWoo\Rules\Order_Created_Via' ) &&
    $rule instanceof \AutomateWoo\Rules\Order_Created_Via
    ) {
    $choices['yoohw-order-duplicate'] = 'Order Clone';
    }

    return $choices;
    }

    add_filter( 'automatewoo/rules/preloaded_select/choices', 'rd_add_yoohw_order_clone_created_via_choice', 10, 2 );

    This temporary workaround marks duplicated orders as yoohw-order-duplicate using WooCommerce’s native Created Via property. The AutomateWoo-specific portion only adds the label to its rule UI; the native order marker is the relevant part of the feature request.

You must be logged in to reply to this topic.