如何在WooCommerce的插件Ajax中调用插件函数?

时间:2019-01-28 09:25:01

标签: php plugins woocommerce

我正在构建自定义付款网关,我需要自定义处理付款调用Ajax并将其重定向到订单视图页面URL。请检查以下示例:

wp-admin/admin-ajax.php?action=custom_process_payment // 404 error


 For example
    //After clicking place order

function custom_process_payment($order_id){
$order = new wc_order($order_id);
// Mark as on-hold (we're awaiting the payment)
                $order->update_status( 'on-hold', __( 'Awaiting offline payment', 'wc-gateway-offline' ) );

}

    <script>
    var success =  funciton(response){
     jQuery.ajax({
                          type: "GET", 
                          url: ajaxurl,
                          dataType : "JSON",
                          data : {action: "custom_process_payment"},
                          //cache: false, 
                          success: function(response){
                            //redirect to order view page

                          }
                        });
    }
    </script>

0 个答案:

没有答案