Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
* Defaults customer meta for shipping country to the good ol' US of A.
* A function like this could be really useful in defaulting to the country that is most commonly purchased from.
* Or even to the base country of the store. Sky's the limit, folks.
* @param null $value A null flag.
* @param string $key The meta key being passed to the customer meta API.
* @return string|null The meta value, or null, if unmodified.
function zao_default_country( $value, $key ) {
remove_filter( 'wpsc_get_visitor_meta_shippingcountry', __FUNCTION__, 15 );
$current_value = wpsc_get_customer_meta( 'shippingcountry' );
add_filter( 'wpsc_get_visitor_meta_shippingcountry', __FUNCTION__, 15 );
if ( $current_value !== '' ) {
return $value;
} else {
return 'US';
add_filter( 'wpsc_get_visitor_meta_shippingcountry', 'zao_default_country', 15, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment