2017-04-27 78 views
1

我正在使用woocommerce處理我的wordpress 上的訂單,並且我正在使用自定義付款網關插件。一切工作完美,除了我想修改感謝頁面,告訴客戶訂單已成功註冊。 過程中支付功能:Woocommerce付款定製謝謝頁

public function process_payment($order_id) { 
    global $woocommerce; 
    $order = new WC_Order($order_id); 
    // Mark as on-hold (we're awaiting the cheque) 
    $order->update_status('on-hold', __('Awaiting payment', 'woocommerce-other-payment-gateway')); 
    // Reduce stock levels 
    $order->reduce_order_stock(); 
    if(isset($_POST[ $this->id.'-admin-note']) && trim($_POST[ $this->id.'-admin-note'])!=''){ 
     $order->add_order_note(esc_html($_POST[ $this->id.'-admin-note']),1); 
    } 
    // Remove cart 
    $woocommerce->cart->empty_cart(); 
    // Return thankyou redirect 
    return array(
     'result' => 'success', 
     'redirect' => $this->get_return_url($order) 
    ); 
} 

我希望當用戶看到的感謝您網頁,他會後,系統會automaticaly重定向。

我不想改變像陣列上的重定向URL:

'redirect' => 'http://example.com/' 

我想他看到頁面後重定向他,我怎麼能設法做到這一點?

在此先感謝。

+0

首先你想顯示默認的感謝頁面,然後你想重定向用戶到你的自定義感謝頁面,對不對? –

+0

@MahaDev正好 –

+0

你爲什麼想這樣做?沒有他們的意見,重新引導人們似乎是不好的用戶體驗。你怎麼知道某人讀完了什麼? 爲什麼不創建自定義感謝頁面,或將自定義信息添加到現有的感謝頁面。 – helgatheviking

回答

0

您可以右鍵一些JS代碼重定向到您的自定義成功頁面是這樣的:

<script> 

setTimeout(function(){ 
    //redirect after 3 seconds 
    window.location.href= 'your_custom_url'; 

}, 3000); 

</script> 

你需要編寫代碼的默認謝謝頁。

+0

我在哪裏可以找到感謝頁面? –

+0

我認爲woocommerce /結帳內/ thankyou.php –

+0

嘿嘿謝謝你的回答,只是一兩件事有關在init_fields的「類型」 \t'$這個 - > form_fields =陣列( \t \t \t \t \t「啓用'=>數組( \t \t \t \t \t '標題' \t \t => __( '使能/禁止', 'woocommerce-其他支付網關'), \t \t \t \t \t '類型' \t \t \t => '複選框', \t \t \t \t \t '標籤' \t \t => __( '啓用自定義付款', 'woocommerce-其他支付網關'), \t \t \t \t \t '默認' \t \t =>'是' \t \t \t \t \t),'如果我想插入html/js代碼應該使用什麼類型? –