如何从评论/评论中获取woocommerce用户账单地址

弗兰·戈多伊

选中“只能由“已验证的所有者”留下评论”。帐单地址输入是必填项。

该代码位于woocommerce_review_before_comment_text挂钩函数调用内我去过的最接近的是:$user_data = get_user_by('id', $comment->user_id);,但是没有客户地址。

法汉·谢赫(Faham Shaikh)

欢迎来到社区。

为了获得帐单地址,您需要获取用户元数据而不是用户对象,除非您也想要用户对象。因此,您的代码应如下所示:

$billing_address_1 = get_user_meta( $comment->user_id, 'billing_address_1', true );
$billing_address_2 = get_user_meta( $comment->user_id, 'billing_address_2', true );
$billing_city = get_user_meta( $comment->user_id, 'billing_city', true );
$billing_state = get_user_meta( $comment->user_id, 'billing_state', true );
$billing_country = get_user_meta( $comment->user_id, 'billing_country', true );
$billing_postcode = get_user_meta( $comment->user_id, 'billing_postcode', true );

您可以将其连接起来以构建完整的地址,也可以根据需要单独使用它们。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章