【发布时间】:2021-12-13 08:38:26
【问题描述】:
我正在尝试在 Woocommerce 上构建自定义支付网关。 我正在尝试从 process_payment 重定向到付款页面的新页面。
是否有任何正确的方法可以重定向到页面,并且我可以传递我需要的数据?
我的文件夹结构:
wp-content
|_ plugins
|_ my-payment
|_ redirect_page.php
wc_my_gateway.php
到目前为止我在 wc_my_gateway.php 中编辑的 process_payment 函数:
public function process_payment($order_id)
{
global $woocommerce;
$order = new WC_Order($order_id);
// todo something ...
$redirect_url = plugin_dir_url(__FILE__) . 'redirect_page.php';
return [
'result' => 'success', // return success status
'redirect' => $redirect_url, // web page url to redirect
];
}
如果有任何进一步的信息需要,请随时发表评论。
【问题讨论】:
-
错误是什么?
-
@Bhautik 感谢您的评论。我什至无法重定向到我想要的页面...
Failed to load resource: the server responded with a status of 500 ()我认为这是因为我没有正确设置重定向 URL。所以我正在寻找一种正确的方法来重定向到一个页面,并且我可以将数据传递到新页面。 -
你检查错误日志了吗?
标签: php wordpress woocommerce hook-woocommerce