Code-Snippets-Functions/Execute a function on a child site/WooCommerce/set-user-billing-and-shipping-country-programmatically.txt

8 lines
235 B
Text

$country_code = 'US';
// Get the WC_Customer instance object from user ID
$customer = new WC_Customer( $user_id );
$customer->set_billing_country( $country_code );
$customer->set_shipping_country( $country_code );
$customer->save();