Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi James,

    Really appreciate the follow-through and the thoughtful update. Your proposed default exclusions are absolutely the right direction – and honestly, they align perfectly with what we discovered in troubleshooting.

    Cloned orders should never inherit transaction-bound Stripe data. Every one of the keys you listed represents either a previously-consumed PaymentIntent, a charge reference, a customer token, or financial metadata tied to a different order. Pulling those into a clone doesn’t just cause edge-case issues… it guarantees unpredictable behavior for users who aren’t expecting it.

    Excluding the full set by default is a smart and safe move. Anyone who truly needs those keys copied (which will be a fraction of a fraction of users) has a clear, documented way to restore them via your filter.

    From my perspective, this change:
    > Dramatically improves reliability for everyone
    > Eliminates the most common Stripe error that appears on cloned paid orders
    > Keeps reporting data accurate
    > Reduces support load for both sides
    > Makes cloning behave exactly the way users “expect” without surprises

    So yes, I’m completely on board. This will make cloning far more intuitive for your entire user base, and it future-proofs Stripe integration in a way that just makes sense.

    Thanks again for the quick response and the willingness to refine the plugin at this level. It’s great seeing this evolve in real time.

    Snippet: keep payment method on cloned orders: Add this as a new snippet (Run everywhere).

    /* WooCommerce ~ Clone Orders ~ Preserve Payment Method – When cloning an order, allow _payment_method and _payment_method_title to be copied to the new order so the gateway is preselected on the clone. */

    add_filter( ‘cdo_wc_clone_order_ignore_meta_keys’, function( $ignore_meta_keys, $original_order_id, $original_order ) {
    if ( ! is_array( $ignore_meta_keys ) ) {
    $ignore_meta_keys = array();
    }
    // Meta keys we want to ALLOW on clones.
    $allow_keys = array(
    ‘_payment_method’,
    ‘_payment_method_title’,
    );
    // Remove the allowed keys from the ignore list.
    $ignore_meta_keys = array_values(
    array_diff( $ignore_meta_keys, $allow_keys )
    );
    return $ignore_meta_keys;
    }, 20, 3 );

    What this does:
    > The cloner builds its default $ignore_meta_keys (which includes _payment_method and _payment_method_title).
    > This filter runs and removes those two from the ignore array.
    > Result: when you clone an order:
    >>The new order does get _payment_method (e.g. stripe) and _payment_method_title copied.
    >>But your other snippet still ensures no _stripe_intent_id or other Stripe transaction meta is copied.

    So:
    > Cloned order will show Stripe already selected as the payment method.
    > Cloned order will not be tied to the old PaymentIntent.
    > Your two existing active snippets remain:
    >> Disable Level 3 Data (prevents the Level 3 mismatch error).
    >> Ensure Cloned Orders are Stripe-Clean (adds Stripe meta to the ignore list).

    Important functional warning:
    > This (untested) snippet (preserve payment method) works alone
    > Cloning paid orders safely requires the Stripe-clean snippet active
    > Level 3 snippet is optional but recommended

    My solution, end-to-end…

    1. To avoid Level 3 pricing mismatch errors: 1) Stripe does not reject orders 2) No random payment failures and 3) Checkout works consistently.

      // Disable Stripe Level 3 data for all WooCommerce Stripe payments.

      add_filter( ‘wc_stripe_generate_create_intent_request’, ‘tofw_disable_stripe_level3’, 20, 3 );
      function tofw_disable_stripe_level3( $request, $order, $prepared_source ) {
      // If Level 3 data is present, remove it so Stripe never validates it.
      if ( isset( $request[‘level3’] ) ) {
      unset( $request[‘level3’] );
      }
      return $request;
      }

      2. And to clone paid orders: Clone starts clean, No PaymentIntent carried over, No Stripe aborts, No manual cleanup, and Payments work immediately.

      /*
      TOFW: Make cloned orders Stripe-clean.
      Uses the official cdo_wc_clone_order_ignore_meta_keys filter from “Clone / Duplicate Orders for WooCommerce” to prevent copying Stripe payment intent / charge / fee meta to the new cloned order.
      */

      function tofw_exclude_stripe_meta_from_clone( $ignore_meta_keys, $original_order_id, $original_order ) {
      if ( ! is_array( $ignore_meta_keys ) ) {
      $ignore_meta_keys = array();
      }
      // Meta keys that should NOT be copied to cloned orders.
      // _stripe_intent_id is the critical one for avoiding “transaction already consumed” on clones.
      $stripe_keys_to_ignore = array(
      ‘_stripe_intent_id’, // PaymentIntent ID – MUST be ignored on clones.
      ‘_stripe_charge_id’, // Charge ID – avoid clones tying to original charge for refunds.
      ‘_stripe_customer_id’, // Customer ID – optional, but keeps clones cleaner.
      ‘_stripe_upe_saved_payment_method’, // Saved payment method token.
      ‘_stripe_mode’, // Live/test mode flag from original.
      ‘_stripe_balance_transaction’, // Balance transaction reference.
      ‘_stripe_fee’, // Fee meta from original order.
      ‘_stripe_net’, // Net payout meta from original order.
      ‘_stripe_total_fee’,
      ‘_stripe_total_net’,
      );
      foreach ( $stripe_keys_to_ignore as $meta_key ) {
      if ( ! in_array( $meta_key, $ignore_meta_keys, true ) ) {
      $ignore_meta_keys[] = $meta_key;
      }
      }
      return $ignore_meta_keys;
      }
      add_filter( ‘cdo_wc_clone_order_ignore_meta_keys’, ‘tofw_exclude_stripe_meta_from_clone’, 10, 3 );

    Viewing 3 replies - 1 through 3 (of 3 total)