Filters to override default country and state on checkout form

This commit is contained in:
Mike Jolley 2012-02-21 16:59:22 +00:00
parent 00aec064c5
commit f1b699f7a6
2 changed files with 9 additions and 4 deletions

View File

@ -564,16 +564,19 @@ class WC_Checkout {
else : else :
$default_country = apply_filters('default_checkout_country', $woocommerce->countries->get_base_country());
$default_state = apply_filters('default_checkout_state', $woocommerce->countries->get_base_state());
// If we are here then the user is not logged in - try to use the session data, otherwise default to base // If we are here then the user is not logged in - try to use the session data, otherwise default to base
if ($input == "billing_country") return ($woocommerce->customer->get_country()) ? $woocommerce->customer->get_country() : $woocommerce->countries->get_base_country(); if ($input == "billing_country") return ($woocommerce->customer->get_country()) ? $woocommerce->customer->get_country() : $default_country;
if ($input == "billing_state") return ($woocommerce->customer->get_state()) ? $woocommerce->customer->get_state() : $woocommerce->countries->get_base_state(); if ($input == "billing_state") return ($woocommerce->customer->get_state()) ? $woocommerce->customer->get_state() : $default_state;
if ($input == "billing_postcode") return ($woocommerce->customer->get_postcode()) ? $woocommerce->customer->get_postcode() : ''; if ($input == "billing_postcode") return ($woocommerce->customer->get_postcode()) ? $woocommerce->customer->get_postcode() : '';
if ($input == "shipping_country") return ($woocommerce->customer->get_shipping_country()) ? $woocommerce->customer->get_shipping_country() : $woocommerce->countries->get_base_country(); if ($input == "shipping_country") return ($woocommerce->customer->get_shipping_country()) ? $woocommerce->customer->get_shipping_country() : $default_country;
if ($input == "shipping_state") return ($woocommerce->customer->get_shipping_state()) ? $woocommerce->customer->get_shipping_state() : $woocommerce->countries->get_base_state(); if ($input == "shipping_state") return ($woocommerce->customer->get_shipping_state()) ? $woocommerce->customer->get_shipping_state() : $default_state;
if ($input == "shipping_postcode") return ($woocommerce->customer->get_shipping_postcode()) ? $woocommerce->customer->get_shipping_postcode() : ''; if ($input == "shipping_postcode") return ($woocommerce->customer->get_shipping_postcode()) ? $woocommerce->customer->get_shipping_postcode() : '';

View File

@ -152,6 +152,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* woocommerce_file_download_path hook * woocommerce_file_download_path hook
* Order screen has icons showing customer notes + order notes * Order screen has icons showing customer notes + order notes
* Fixed category hierarchy (typo) * Fixed category hierarchy (typo)
* Delete term cleanup
* Filters to override default country and state on checkout form
= 1.4.4 - 18/02/2012 = = 1.4.4 - 18/02/2012 =
* Fix for remove coupon links after ajax update of shipping * Fix for remove coupon links after ajax update of shipping