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 billing_country and shipping_country programmatically?
I tried WC()->customer->set_shipping_country('US');
this set only the country for the cart and checkout page but does not send the country by submit.
You missed the
WC_Customer
save()
method…You can use the following from a static or dynamic user ID (the user Id is mandatory):
Now it's saved as user meta data in the database.