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!

WooCommerce: set the default billing country on the checkout

PHP snippet: Set Default Billing Country or State @ WooCommerce Checkout Page


/**
 * @snippet       Set Default Billing Country @ WooCommerce Checkout Page
 * @how-to        Get CustomizeWoo.com FREE
 * @source        https://businessbloomer.com/?p=601
 * @author        Rodolfo Melogli
 * @compatible    Woo 3.5.4
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

// Example 1: default state to OREGON

add_filter( 'default_checkout_billing_state', 'bbloomer_change_default_checkout_state' );
 
function bbloomer_change_default_checkout_state() {
  return 'OR'; // state code
}

// Example 2: default country to United States

add_filter( 'default_checkout_billing_country', 'bbloomer_change_default_checkout_country' );

function bbloomer_change_default_checkout_country() {
  return 'US'; 
}

Share:

Leave a Reply