Updating Woocommerce Orders Programmatically(以编程方式更新 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 订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:以编程方式更新 Woocommerce 订单
基础教程推荐
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01