diff --git a/classes/shortcodes/class-wc-shortcode-cart.php b/classes/shortcodes/class-wc-shortcode-cart.php index b72b1293919..5147ce0b801 100644 --- a/classes/shortcodes/class-wc-shortcode-cart.php +++ b/classes/shortcodes/class-wc-shortcode-cart.php @@ -46,7 +46,8 @@ class WC_Shortcode_Cart { $woocommerce->customer->calculated_shipping( true ); $country = $_POST['calc_shipping_country']; $state = $_POST['calc_shipping_state']; - $postcode = $_POST['calc_shipping_postcode']; + $postcode = apply_filters( 'woocommerce_shipping_calculator_enable_postcode', true ) ? stripslashes( $_POST['calc_shipping_postcode'] ) : ''; + $city = apply_filters( 'woocommerce_shipping_calculator_enable_city', false ) ? stripslashes( $_POST['calc_shipping_city'] ) : ''; if ( $postcode && ! $validation->is_postcode( $postcode, $country ) ) { $woocommerce->add_error( __( 'Please enter a valid postcode/ZIP.', 'woocommerce' ) ); @@ -58,8 +59,8 @@ class WC_Shortcode_Cart { if ( $country ) { // Update customer location - $woocommerce->customer->set_location( $country, $state, $postcode ); - $woocommerce->customer->set_shipping_location( $country, $state, $postcode ); + $woocommerce->customer->set_location( $country, $state, $postcode, $city ); + $woocommerce->customer->set_shipping_location( $country, $state, $postcode, $city ); $woocommerce->add_message( __( 'Shipping costs updated.', 'woocommerce' ) ); } else { diff --git a/readme.txt b/readme.txt index 2656c406695..1f159d6be7f 100644 --- a/readme.txt +++ b/readme.txt @@ -165,6 +165,9 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc == Changelog == += X = +* Tweak - Support for the city field in shipping calc (filterable) + = 2.0.7 - 12/04/2013 = * Feature - Option for GA _setDomainName. * Tweak - Removed rounding when option to round at subtotal is set. diff --git a/templates/cart/shipping-calculator.php b/templates/cart/shipping-calculator.php index 6dc1d9baf58..759e7b55d62 100644 --- a/templates/cart/shipping-calculator.php +++ b/templates/cart/shipping-calculator.php @@ -4,73 +4,88 @@ * * @author WooThemes * @package WooCommerce/Templates - * @version 1.6.4 + * @version 2.0.8 */ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly global $woocommerce; -if ( get_option('woocommerce_enable_shipping_calc')=='no' || ! $woocommerce->cart->needs_shipping() ) return; +if ( get_option('woocommerce_enable_shipping_calc')=='no' || ! $woocommerce->cart->needs_shipping() ) + return; ?>
+

+
+

+

customer->get_shipping_country(); - $current_r = $woocommerce->customer->get_shipping_state(); - - $states = $woocommerce->countries->get_states( $current_cc ); + $current_r = $woocommerce->customer->get_shipping_state(); + $states = $woocommerce->countries->get_states( $current_cc ); + // Hidden Input if ( is_array( $states ) && empty( $states ) ) { - // Hidden - ?> - - - - - - + + - -

-

- -

-
+ + + +

+ +

+ + + + + +

+ +

+ + +

+ nonce_field('cart') ?>
- + \ No newline at end of file