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.