Is it possible to automatically set the status to “on hold” after a successful payment?
I tried it with this script. It works with Stripe. Unfortunately, it doesn’t work with this PayPal plugin. Please help me. Thank you!
Best regards,
Anton
add_action( ‘woocommerce_thankyou’, ‘custom_woocommerce_auto_complete_order’ );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
// Check if the order was paid with Stripe
if ( $order->get_payment_method() == ‘stripe’ ) {
// Update order status to ‘on-hold’
$order->update_status( ‘on-hold’, ‘Order automatically put on hold, since it was paid with Stripe.’ );
}
// Check if the order was paid with PayPal
if ( $order->get_payment_method() == ‘paypal’ ) {
// Update order status to ‘on-hold’
$order->update_status( ‘on-hold’, ‘Order automatically put on hold, since it was paid with PayPal.’ );
}
}
Open
Last updated: January 10, 2025
0 comments
Log in to comment on this feature request.