35
This is a simple PGP snippet that I successfully used on a bunch of websites in order to set the default Billing country or state. This is a great way to save the user some time during checkout (and therefore increase your conversion rate) in case you almost exclusively sell to customers located in a given country or state. Nothing else to say, just… enjoy!
PHP snippet: Set Default Billing Country or State @ WooCommerce Checkout Page
/** * @snippet Set Default Billing Country @ WooCommerce Checkout Page * @how-to Get tutoraspire.com FREE * @source https://tutoraspire.com/?p=601 * @author Tutor Aspire * @compatible Woo 3.5.4 * @donate $9 https://tutoraspire.com */ // Example 1: default state to OREGON add_filter( 'default_checkout_billing_state', 'tutoraspire_change_default_checkout_state' ); function tutoraspire_change_default_checkout_state() { return 'OR'; // state code } // Example 2: default country to United States add_filter( 'default_checkout_billing_country', 'tutoraspire_change_default_checkout_country' ); function tutoraspire_change_default_checkout_country() { return 'US'; }