John Davidson

wordpress - display custom fields in coocommerce my-address.php file

0 comments
Message:


i'm using a plugin to add some custom fields to the checkout page also display them in my-account page the plugin works perfectely but i need now to add a field to my-address.php template bellow is my code :


echo $custom_user_meta = get_user_meta(get_current_user_id(), '_billing_mr_ou_mme', true);

this code is not displaying anything i'm sur that the meta name of my custom field is _billing_mr_ou_mme but nothing is displaying

but when i do :
echo $custom_user_meta = get_user_meta(get_current_user_id(), 'billing_phone', true);

the code works, so my code is not working only with the custom fields but works with the defaut woocommerce fields, can any one help

the name of the plugin is : https://wordpress.org/plugins/flexible-checkout-fields/



My Answer:
It seems like the issue might be with the way you are trying to retrieve the custom field value. Instead of using get_user_meta, you can try using get_user_meta(get_current_user_id(), 'billing_mr_ou_mme', true) directly without the underscore before the field name.

Here is the updated code snippet:

php
echo $custom_user_meta = get_user_meta(get_current_user_id(), 'billing_mr_ou_mme', true);


Make sure that the meta key 'billing_mr_ou_mme' is correct and matches the one set in the plugin. If it still doesn't work, you can try debugging by checking if the custom field value is being saved correctly in the database.

If you continue to face issues, you can reach out to the plugin support for further assistance.

Rate this post

3 of 5 based on 7963 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us