【发布时间】:2019-07-18 19:12:50
【问题描述】:
我需要将包含订单详细信息的 xml 文件导出到我的本地机器。
我有两个问题:
- 我使用了
woocommerce_thankyou挂钩,但每次用户访问订单摘要时都会触发。相反,我现在使用woocommerce_new_order。但是,当存储 xml 文件时出现错误时,我会在结帐页面上看到一个 空错误框。 如何在woocommerce_new_order挂钩期间捕获错误触发并使用 php 在错误框中显示它? - 我的服务器没有安装 ssh2,所以我尝试使用phpseclib。当我在示例文件中运行它时,它就像一个魅力,但是当我在
woocommerce_new_order挂钩期间调用它时,我无法连接到我的本地计算机。我没有收到任何错误,该网站只是结束。 有没有办法连接到在woocommerce_new_order挂钩期间工作的本地 Windows 机器?
这是我目前的代码:
function save_xml($order_id) {
set_include_path(getcwd());
include('Net/SSH2.php');
$ssh = new Net_SSH2($host);
if (!$ssh->login($user, $pass)) {
// This is where I need to send an error to woocommerce
} else {
$ssh->exec($run); // Here I run some command
}
}
add_action( 'woocommerce_new_order', 'save_xml', 10, 3 );
【问题讨论】:
-
请将答案放在答案块中。稍后,您可以接受自己的答案。另见How does accepting an answer work?
标签: php wordpress ssh woocommerce phpseclib