Purchase/orders details are missing in my account page when using cred form with woocommerce.
We created a registration form with woocommerce product "hidden link" and follow the instruction here
https://toolset.com/course-lesson/charge-users-for-registering-premium-accounts/
Problem Is
frontend view: after the customer registered and paid using cred form with woocommerce. the customer has no purchase/order details in the my account page.
backend view: In the woocommerce > orders the status was complete but the customer mark as guest.
What we need is
woocommerce order details must be tag or mark to the registered user
Can you help us solve this?
Are missing something?
Can you provide a custom function for this?
Website: hidden link
Thanks
Hello,
Thanks for the details, I can duplicate the same problem, and it should be able to set the new user as the order's customer without any custom codes, so I have escalated it, will update here if there is any news.
Hi
Can you update us as soon as the bugs fixed.
Thanks
Our 2nd tier support has provided a workaround for it, you can add below codes into your theme file functions.php:
/**
* Set the user ID for customer in the order used to charge to register a user
*/
function ts_new_user_id( $data ){
if( !isset($data['extra_data']['cred_form_id']) || $data['extra_data']['cred_form_id'] != 123){
return;
}
if ( isset( $data['transaction_id'] ) ) {
$order_id = $data['transaction_id'];
$user_id = get_post_meta( $order_id, '_cred_post_id', true );
if ( isset( $user_id ) ){
update_post_meta( $order_id, '_customer_user', $user_id );
}
}
}
add_action( 'cred_commerce_after_order_completed', 'ts_new_user_id' );
Please replace 123 with your user form's ID, and test again
Hi
We tried the above code and tested it but its not working
Can you confirm that function is working?
Thanks
Hi,
Thank you for waiting.
Luo is on vacation so I'll be following up on this ticket.
I've performed some tests on my website and I was able to make this work, using a slightly updated code:
function ts_new_user_id( $data ){
if ( isset( $data['transaction_id'] ) ) {
$order_id = $data['transaction_id'];
$user_id = get_post_meta( $order_id, '_cred_post_id', true );
if ( isset( $user_id ) ){
update_post_meta( $order_id, '_customer_user', $user_id );
}
}
}
add_action( 'cred_commerce_after_order_completed', 'ts_new_user_id' );
regards,
Waqar
My issue is resolved now. Thank you!