Sorry! Internet Explorer is not supported on this site. Please view on Chrome, Firefox, or Edge.

Having fun at Zao is one of our values. We’ve put limited animated flourishes throughout our site to communicate our love of levity. We also recognize that onscreen movement is not fun or possible for everyone. We've turned off all our animations for you per your browser's request to limit motion. That said, we don't want you to miss out on the party.

Here's a funny joke to enjoy!

Where does the General keep his armies?

In his sleevies!

How To: Set the Default Shipping Country in WP eCommerce

There are a few really great scenarios to set a default shipping country for your WP eCommerce shop.  In a past iteration, we actually defaulted to the base country and region of the shop itself.  There was some decent, though flawed and short-sighted logic behind this.  We eventually reverted that behavior in favor of requiring users to choose their own shipping location.

While this behavior is more intuitive, from time to time, we do get users asking for the ability to default to a specific country.  While the previous behavior is sometimes requested, other scenarios might include defaulting to the country where you receive most of your orders from.  This could vary wildly depending on season or product line.  The code below is a helpful start to defaulting to any country you desire.  Note: The filter being used should return a country’s ISO code.

You’ll notice we’re using the variable filter for the visitor meta API that is specific to the key being called.  There is also the more generic wpsc_get_visitor_meta filter, but with the variable filter, we don’t need to check for the key being called.

Boom!

Join the Conversation

6 Comments

  1. Justin I am getting a warning Missing argument 2 for zao_default_country(). If I remove the $key it seems to work or am I missing something

    1. Hi John,

      Hmm, that’s odd, as three parameters should actually be passed (value, key, and visitor ID). Perhaps confirm that you’ve added the action with the “2” for the last parameter, as in the gist? Otherwise, you should be fine to go ahead and remove the $key variable, as it is unused.

      Thanks for commenting!

Leave a comment

Your email address will not be published. Required fields are marked *