Set user billing and shipping country programmatically in WooCommerce

Set user billing and shipping country programmatically in WooCommerce on your child site.

Snippet Type

Execute on Child Sites

Snippet

$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();
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.