You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WooCommerce支付完成后自定义订单状态延迟触发或未触发问题排查求助

Troubleshooting Delayed/Untriggered Custom Order Status for CARDPAY Orders

Hey there, let's walk through some actionable troubleshooting steps and fixes for your order status issue. I'll break this down into easy-to-follow checks and alternatives since you're not a full-time developer.

1. Verify if the Hook is Actually Being Triggered

The woocommerce_payment_complete_order_status hook only fires when the payment gateway explicitly calls WooCommerce's payment_complete() method. Not all payment gateways do this—some might directly update the order status without using this standard method.

To confirm if your hook is running, add temporary logging to your code (you can remove this later):

add_action( 'woocommerce_payment_complete_order_status', 'change_status_of_paid_orders', 10, 3 );
function change_status_of_paid_orders( $status, $order_id, $order ) {
    // Write debug info to WooCommerce logs
    error_log( "Custom status hook triggered for order #$order_id. Current status: $status" );
    error_log( "Order #$order_id payment method: " . $order->get_payment_method() );
    return 'card-on-hold';
}

Then check WooCommerce's logs:

  • Go to WooCommerce > Status > Logs
  • Look for a log file named debug.log (or the latest fatal error log)
  • Search for the messages you added. If you don't see them, the hook isn't being triggered by your CARDPAY gateway.

2. Check for Conflicts with WooCommerce Order Status Manager

Even though you're only using the plugin for PDFs and BACS info, it might be overriding order status logic behind the scenes. Try this test:

  • Temporarily disable the WooCommerce Order Status Manager plugin
  • Process a test CARDPAY order
  • If the status updates immediately to card-on-hold, the plugin is conflicting with your code.

If that's the case, check the plugin's settings first—many order status plugins let you map payment methods to custom statuses directly (no code needed!). Look for an option like "Payment Method to Status Mapping" or similar.

3. Confirm Your Custom Status is Properly Configured

Make sure card-on-hold is set up correctly in the Order Status Manager plugin:

  • Go to the plugin's settings page
  • Verify card-on-hold is enabled and assigned to the correct status group (e.g., "Processing" or "On Hold" groups)
  • Ensure the status allows transitions from your gateway's default paid status (like processing or completed)

4. Address Delayed Triggers (Asynchronous Payment Notifications)

If the status updates after a delay, your CARDPAY gateway might be using asynchronous payment confirmation—meaning it sends a payment success notification to your site after the initial order is created. This is normal for many gateways, but you can:

  • Check your gateway's settings for a "Synchronous Payment Confirmation" option (if available)
  • Look at the order notes in WooCommerce (under the order details page) to see when the payment confirmation was received—this will tell you if the delay is coming from the gateway or your site.

5. Try a More Reliable Hook Alternative

If the original hook isn't working, switch to woocommerce_order_status_changed, which fires every time an order's status changes. This lets you target CARDPAY orders specifically when they move to a paid status:

add_action( 'woocommerce_order_status_changed', 'update_cardpay_to_custom_status', 10, 4 );
function update_cardpay_to_custom_status( $order_id, $old_status, $new_status, $order ) {
    // Only target CARDPAY orders that just moved to a paid status
    if ( $order->get_payment_method() === 'cardpay' && in_array( $new_status, array( 'processing', 'completed' ) ) ) {
        $order->update_status( 'card-on-hold', 'Updated custom status for CARDPAY payment' );
    }
}

This is more flexible because it doesn't depend on the gateway using payment_complete().

6. Check for Fatal Errors

Hidden errors might be stopping your code from running. Go to WooCommerce > Status > Logs and look for any fatal-errors logs. If you see errors related to your custom code or the Order Status Manager plugin, that's a clue to fix (e.g., typos in the status slug card-on-hold—make sure it matches exactly what you created in the plugin).


内容的提问来源于stack exchange,提问作者RaDium

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 05:27:44