简体   繁体   English

WooCommerce-如何为开发测试重新下订单

[英]WooCommerce - How to Reprocess a Placed Order for Development Testing

I'm building a small plugin (WordPress/WooCommerce) that sends order data from a placed order to an external system. 我正在构建一个小插件(WordPress / WooCommerce),该插件将已下订单的订单数据发送到外部系统。

The sequence of the process is simple. 该过程的顺序很简单。 When this action is triggered: 触发此操作后:

add_action('woocommerce_thankyou', array($this, 'xc_woocommerce_thankyou'));

I use wp_remote_post to send the order data to my external system. 我使用wp_remote_post将订单数据发送到我的外部系统。

The problem is, I'm having to run these tests a lot because I'm pulling data from various metadata sources (from other plugins) in WooCommerce and so I need to test repeatedly. 问题是,我必须大量运行这些测试,因为我要从WooCommerce中的各种元数据源(从其他插件)中提取数据,因此我需要重复进行测试。 This takes a lot of time as I have to set the cart up again and again before placing the order. 这需要很多时间,因为我必须在下订单之前一次又一次地设置好购物车。

My question: is there a way to "reverse" the "Place Order" so that the cart gets reinstated so that I can run it repeatedly for tests? 我的问题:是否有一种方法可以“撤消”“下订单”,以便恢复购物车,以便我可以反复运行它进行测试?

woocommerce_thankyou 

hook runs every time the thankyou page loads. 钩子在每次thankyou页面加载时运行。 So process your order and once you land on the thank you page just keep refreshing the page and your method will run each time with the same order number and cart information. 因此,处理您的订单,一旦您进入“谢谢”页面,请继续刷新页面,您的方法将每次以相同的订单号和购物车信息运行。

Because of this I would recommend using the 因此,我建议您使用

woocommerce_order_status_processing

hook after you have finished your testing or similar as it only runs once. 完成测试或类似测试后,请执行钩子,因为它只能运行一次。 This method also allow you to if there is an issue re-send the order by changing the order status to pending and then back to processing. 此方法还允许您在出现问题时通过将订单状态更改为“待处理”然后重新进行处理来重新发送订单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM