2017-04-26 22 views
0

カスタムアクションを実行するたびに「注文更新」というメッセージが表示されます。カスタム注文アクション成功メッセージ

カスタム注文アクションを実行した後にこのメッセージを非表示にする方法はありますか?たとえば、自分のアクションが処理されない場合

function _custom_order_action_process($order) { 

    // some code 
    // some code 
    // some code 

    if (! $valid1) { 
     // Oooops... 
     return; 
    } 
    if (! $valid2) { 
     return; 
    } 

    //here we go... 

} 
add_action('woocommerce_order_action_custom_order_action','_custom_order_action_process'); 

答えて

1

メッセージ値を変更することができます。
これにはredirect_post_locationを使用できます。

function _custom_order_action_process($order) { 

    // some code 
    // some code 
    // some code 

    if (! $valid1) { 
     // Oooops... 

     add_filter('redirect_post_location', 'redirect_post_location', 99); 
    } 
    if (! $valid2) { 

     add_filter('redirect_post_location', 'redirect_post_location', 99); 

    } 

    //here we go... 

} 
add_action('woocommerce_order_action_custom_order_action','_custom_order_action_process'); 


function redirect_post_location($location) { 
    remove_filter('redirect_post_location', __FUNCTION__, 99); // remove this filter so it will only work with your validations. 
    $location = add_query_arg('message', 99, $location); // 99 is empty message, it will not show. Or if by any chance it has a message, you change to higher number. 
    return $location; 
} 
+0

ありがとうございます!出来た。しかし、私はそれがどのように動作するのか分かりません。これらの "クエリargs"は、POSTリクエストのWordPressプロセスの変数ですか?そうですか? – lcssanches

関連する問題