以编程方式更新Woocommerce订单 [英] Updating Woocommerce Orders Programmatically

查看:55
本文介绍了以编程方式更新Woocommerce订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Wordpress上运行Woocommerce的电子商务网站,并且运行该公司的公司已将那里的运输系统更改为外部公司,后者将产品存储在他们的仓库中,并在购买产品时将其运输.

I have an eCommerce site running Woocommerce on top of Wordpress, and the company running it has changed there shipping system to an external company who stores the products in their warehouse and ships the products when they are bought.

在自动化方面,可以下载有关新订单的信息并将其发送给货运公司,但是,当他们使用发送的订单的XML和相关的跟踪号对我进行回复时,我需要能够自动更新订单的系统(包括发送必要的电子邮件).但是,我目前唯一知道的方法是更新MySQL数据库.但是通过这种方法,自动电子邮件系统将被覆盖和忽略.

In terms of automation, downloading information on new orders and sending it to the shipping company is fine, but when they respond to me with an XML of the orders sent and the associated tracking numbers, I need to be able to have a system that automatically updates the orders (including sending out the emails necessary). However, the only way I currently know how to do that is to update the MySQL database. But with that method, the automated email system is overridden and ignored.

有人知道我如何以编程方式更新订单状态和其他信息,这将允许Woocommerce的内部功能以与手动登录到管理端并更新订单相同的方式执行吗?

Does anyone know how I can update orders statues and other information programmatically, which would allow Woocommerce's internal functions to be executed in the same way as manually logging into the admin side and updating the order?

推荐答案

找到解决方案了吗?

下面的代码可将订单标记为已完成,但不会执行您在管理员中描述的其他操作

The code below works to mark an order as complete, but does not execute other actions as you describe in the admin

// create a new checkout instance and order id
$checkout = new WC_Checkout();
$this_order_id = $checkout->create_order();

$order = new WC_Order($this_order_id);
$order->update_status('completed');

这篇关于以编程方式更新Woocommerce订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆