duanmu8911 2019-04-06 03:33
浏览 37

销售虚拟或下载产品时如何使自定义支付网关状态为“处理”,而不是“已完成”?

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?

  1. 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:

  1. 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.

  • 写回答

0条回答 默认 最新

    报告相同问题?