Questions tagged [usermetadata]
29 questions
3
votes
1 answer
Save WooCommerce checkout custom field as user meta data
I want to add my custom registration field to my checkout page form.
I'm using this code for adding custom field to my registration area.
By the way, i'm using my checkout fields in to my registration fields.
add_filter(…

Şenol Üstün
- 63
- 5
3
votes
2 answers
Show or hide shipping methods based on user meta data in WooCommerce
I have a code to hide shipping for non-wholesale customers, please help me redo it, I need to hide the shipping option for wholesale customers.
/**
* Removes shipping methods for non-wholesale customers.
* Please be sure to clear your WooCommerce…

Spirit
- 43
- 3
2
votes
1 answer
Hide specific payment method for new customers in WooCommerce 5.6+
I created a script checking if the user has a a completed order. If the user has no completed order it is disabling the payment method "cheque". This works but after adding it my functions.php i get serious performance problems on my page while…

public9nf
- 1,311
- 3
- 18
- 48
2
votes
1 answer
Set WooCommerce user billing and shipping country programmatically
I use WooCommerce and I build some custom functions.
The last thing what I want is set the country for billing and shipping programmatically.
I removed the input billing_country and shipping_country from the checkout page.
Is there a way to set the…

Bert
- 55
- 6
2
votes
2 answers
How to fill custom checkout field with previously entered value, like default WooCommerce checkout fields?
I have added a custom field using the below code:
add_action( 'woocommerce_before_order_notes', 'bbloomer_add_custom_checkout_field' );
function bbloomer_add_custom_checkout_field( $checkout ) {
$current_user = wp_get_current_user();
…

dc09
- 386
- 2
- 17
2
votes
1 answer
Get checkout custom field submitted value using WC_Checkout get_value() method in WooCommerce
In WooCommerce checkout page, I have added a custom field using the code below:
add_action( 'woocommerce_before_order_notes', 'bbloomer_add_custom_checkout_field' );
function bbloomer_add_custom_checkout_field( $checkout ) {
$current_user =…

dc09
- 386
- 2
- 17
2
votes
1 answer
Updating WordPress account email with WooCommerce billing email after checkout
I need update WordPress account email with woocommerce billing email after successful checkouts. I used this code but it does not work :
/* Update account email based on woocommerce billing email */
add_filter( 'woocommerce_thankyou' ,…

Omid Toraby
- 190
- 11
2
votes
2 answers
Update WooCommerce User programmatically when creating a user
Im trying to create a new user programmatically trough a form but Im having problem with getting the phone numer and country set trough wp_create_user - why wont it take the values? First and last name works as expected.
Relevant code:
$user_id =…

Jerry
- 1,069
- 2
- 13
- 31
1
vote
1 answer
Adding some billing fields to WooCommerce My Account Edit account form
By design all three forms - checkout, register and edit_account are the same. So I have to add all needed fields to edit account form, because edit address form from myaccount isn't needed by design at all. I already added all of the fields, but…

libertarian
- 345
- 1
- 15
1
vote
1 answer
Add value to meta_value in user_meta after order is placed
This function updates user_meta with meta_first and meta_second values.
meta_first is textbox with number and meta_second is selectbox.
Now every product will have different values for meta_first and meta_second.
// Update user_meta after…

Rohit kc
- 15
- 4
1
vote
1 answer
Wordpress how to calculate a value for a user and update related custom meta field
I have created a front-end form on Wordpress using Elementor Pro, and it is successfully updating the user meta of the logged in user when submitted.
I would now like to calculate a separate custom meta field, using the values that were submitted in…

Andrew
- 65
- 5
1
vote
1 answer
How to get orders by user meta data in WooCommerce
I wanted to know, how i am able to see all orders with:
user meta key: friseur
user meta value: TestFriseur
This is my code:
// Users query
$user_ids = (array) get_users([
'role' => 'customer',
'number' => - 1,
'fields' …

steffi
- 11
- 1
1
vote
1 answer
Add custom fields to WooCommerce new account Page
In WooCommerce have created an account registration page as in the following code:

Mohannad Najjar
- 53
- 5
1
vote
1 answer
Wordpress | get_user_meta in child themes php file
I'm trying to get the user meta in a file calles "print.php" in my child-theme folder:
define( 'WP_USE_THEMES', true );
$userid = $_GET['id'];
//$all_meta = get_user_meta( $userid );
When I call "get_user_meta()" i get an Error 500.
I already…

Niko
- 21
- 6
1
vote
2 answers
WordPress: Save user meta to post meta on save
I want to add some user meta to a post (in my case WooCommerce product) after saving it. I guess that's the best approach?
I found a solution which does somehting like this: https://wordpress.stackexchange.com/a/273271/96806
But it seems, that it…

Cray
- 5,307
- 11
- 70
- 166