当访问者在我的WooCommerce商店购买新产品时,我使用woocommerce_created_customer钩子在外部数据库上创建一个新用户,其中包含从$customer_id, $new_customer_data, $password_generated参数中获得的一些信息。
例如:
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?
我想在付款完成后再用另一个钩子。但在我的情况下,这是不可能的,因为这是我找到的唯一可以获得未散列用户密码的钩子,这是我非常需要的。
您知道如何在客户创建钩子中获取订单信息吗?
发布于 2022-02-19 07:51:09
订单是在客户之后创建的。
$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'] : '';https://stackoverflow.com/questions/71183093
复制相似问题