[英]How to get the customer id when creating the customer and order at the same time?
[英]How to get the order id that the customer canceled with the hook
我在插件中有另一个 API 用于在网站上下订单,所以我想当客户取消 woocommerce 订单时,我还要取消其他网站订单,我将拥有 Z8F75DB0D15031B 的订单 ID 和其他 3BA927C89B9AB2 的订单 ID wp_post_meta
中的网站
我只想知道如何获取客户取消的订单 ID 以调用订单 ID,而另一个则取消两者
function cancel_SP_order(){
// how to get the order id cancelation with the hook
get_post_meta() ..... // for example
// I get $order_id from wp_post_meta which has the other order id
// I cancel the other
}
add_action('woocommerce_cancelled_order','cancel_SP_order');
如果有更好的方法肯定我欢迎
幸运的是,钩子本身传递了 $order_id。你可以像这样访问它:
function cancel_SP_order( $order_id ){
// I get $order_id passed by the hook to use directly.
// I cancel the other
}
add_action('woocommerce_cancelled_order','cancel_SP_order', 10, 1);
function 名称('10')之后的第一个参数是 function 将运行的优先级。 第二个,'1',是从钩子传递到 function 的参数数量。 在这种情况下,它只是“1”,即您需要的订单 ID。
如果您需要更多帮助,请告诉我?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.