[英]How to get the order information inside the customer creation hook?
当访客在我的 WooCommerce 商店购买新产品时,我使用woocommerce_created_customer
挂钩在外部数据库上创建一个新用户,其中包含我从$customer_id, $new_customer_data, $password_generated
arguments 获得的一些信息。
例如:
function action_woocommerce_created_customer($customer_id, $new_customer_data, $password_generated) {
// Create a new user on external database
}
add_action('woocommerce_created_customer', 'action_woocommerce_created_customer', 10, 3);
出色地。 我需要的是连接到当前订单以获取订单 ID。 在我的商店中,只能结合订单创建用户帐户。 有没有办法在woocommerce_created_customer
挂钩中获取订单信息? 或者这个do_action
是在订单完成之前调用的吗?
我想在付款完成后使用另一个钩子。 但这在我的情况下是不可能的,因为这是我找到的唯一一个可以获取我非常需要的未经哈希处理的用户密码的钩子。
您知道如何在客户创建挂钩中获取订单信息吗?
订单是在客户之后创建的。
$this->process_customer( $posted_data );
$order_id = $this->create_order( $posted_data );
$order = wc_get_order( $order_id );
使用这个钩子来做这些事情。
do_action( 'woocommerce_checkout_order_processed', $order_id, $posted_data, $order );
$posted_data
包含用户名和密码
$username = ! empty( $posted_data['account_username'] ) ? $posted_data['account_username'] : '';
$password = ! empty( $posted_data['account_password'] ) ? $posted_data['account_password'] : '';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.