I'm using a woocommerce payment gateway for selling virtual product, but after payment success, the status will change to Completed! How to make the status change to Processing not Completed?
- I has try to change payment code, but not working.
if($queryInfo['StatusCode'] == 10001)
{
$order->update_status('completed');
if (!$this->is_order_complete($order)) {
$this->confirm_order($order, $payment_result_comments);
$oPayment->ConfirmOrder();
}
}
Change to:
$order->update_status('processing');
I change the update_status to processing, still not working:
- I add a code to functions, Still not working.:
(1)First try:
add_action( 'woocommerce_order_status_changed', 'change_order_status_conditionally', 10, 4 );
function change_order_status_conditionally( $order_id, $status_from, $status_to, $order ) {
if( $order->get_payment_method() === 'onepaid' && $status_from === 'completed' ) {
$order->update_status( 'processing' );
}
}
(2) Add this code to functions, still not working:
add_action( 'woocommerce_payment_complete_order_status', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
$order->update_status( 'processing' );
}
(3) Add this code to functions, still not working:
add_action( 'woocommerce_payment_complete', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
if( $order->has_status( 'completed' ) )
{
$order->update_status( 'processing' );
}
$order = wc_get_order( $order_id );
$order->update_status( 'processing' );
}
Complete the order and add the comments
function confirm_order($order, $comments) {
$order->add_order_note($comments, true);
$order->payment_complete();
}
When callback payment has payed, the status will change to processing, not complete.
Edit:
I am using OnePaid plugin
It can be downloaded from this page in Chinese, where you can click in Wordpress section on the download button.