使用Woo Credits插件时虚拟产品订单状态无法转为Processing的问题求助
Hey there, I’ve run into similar integration headaches between WooCommerce payment tools and order-dependent plugins like StockUnlock. Let’s break down the most reliable ways to force Woo Credits to set orders to Processing instead of skipping straight to Completed:
1. Check Woo Credits Plugin Settings First
Start with the simplest fix—many payment gateways let you configure post-payment order status directly:
- Head to your WordPress admin → WooCommerce → Settings → Payments
- Find the "Woo Credits" gateway and click Manage
- Look for an option like "Order Status After Payment" or equivalent. If it exists, switch it from Completed to Processing.
- Save changes and test a dummy order to confirm the status behaves as expected.
2. Use a WooCommerce Filter to Override the Status
If there’s no built-in setting, add this custom code snippet to your theme’s functions.php file (or a custom plugin for safer long-term use—theme updates won’t overwrite it):
add_filter( 'woocommerce_payment_complete_order_status', 'force_woo_credits_to_processing', 10, 3 ); function force_woo_credits_to_processing( $status, $order_id, $order ) { // Only target orders paid with Woo Credits if ( $order->get_payment_method() === 'woo_credits' ) { return 'processing'; // Force status to Processing } // Leave other payment methods' default status intact return $status; }
This code hooks into WooCommerce’s core payment flow and overrides the status only for Woo Credits transactions, so your other payment gateways won’t be affected.
3. Fallback: Convert Completed Orders to Processing (Post-Payment)
If the filter above doesn’t work (some plugins bypass standard WooCommerce hooks), use this action to retroactively adjust the status when the thank-you page loads:
add_action( 'woocommerce_thankyou_woo_credits', 'convert_woo_credits_order_to_processing' ); function convert_woo_credits_order_to_processing( $order_id ) { if ( ! $order_id ) return; $order = wc_get_order( $order_id ); // Only change status if it's currently Completed and paid with Woo Credits if ( $order->get_status() === 'completed' && $order->get_payment_method() === 'woo_credits' ) { $order->update_status( 'processing', 'Updated status to trigger StockUnlock plugin integration', true ); } }
Quick Tips Before You Start
- Test all changes in a staging environment first to avoid breaking live orders.
- If you’re using a child theme, add the code there instead of the parent theme—this prevents loss during theme updates.
- Double-check that StockUnlock is configured to trigger on Processing orders (it should be, per your original setup).
内容的提问来源于stack exchange,提问作者Kader Gómez

