Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tagging v1.2.2 #48

Merged
merged 6 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.svn/
.idea/
.svn/
52 changes: 36 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ This WooCommerce plugin transforms the text input for states, the city or town.
This will be shown in checkout pages, edit addresses pages, shipping calculator, etc.

## Supported Countries
* Algeria
* Brasil
* Chile
* Guatemala
* Nicaragua
* Nigeria
* Panama
* Russia
* Spain
* Tunisia
* Venezuela

## Requirements
Expand Down Expand Up @@ -43,7 +49,7 @@ If on the off-chance you do encounter issues with the shop/category pages after
Kindly create an issue stating the bug and how you caught it [chitezh/woocommerce_states_places](https://github.com/chitezh/woocommerce_states_places/issues/new)

### Can I suggest a new place or location?
Yes, you can always suggest or request new locations by creating an issue [chitezh/woocommerce_states_places](https://github.com/chitezh/woocommerce_states_places/issues/new).
Yes, you can always suggest or request new locations by creating an issue in [chitezh/woocommerce_states_places](https://github.com/chitezh/woocommerce_states_places/issues/new). Please refer to the [Country Codes](https://github.com/woocommerce/woocommerce/blob/master/i18n/countries.php) using by WooCommerce.

### How do I contribute to the project?
You extend the plugin to cover countries, states and places. we accept pull requests.
Expand Down Expand Up @@ -80,22 +86,36 @@ Fork the repo and make changes to /trunk. Consider reading [Wordpress F.A.Q.](ht
- Luis Sebastian Urrutia Fuentes - [LuisUrrutia](https://github.com/LuisUrrutia)
- Yordan Soares - [YordanSoares](https://github.com/YordanSoares)


## Changelog
* 1.2.1
* Add two new countries places: Panama (PA) and Venezuela (VE).
* 1.2.2 - March 22, 2020
* Added six new countries:
* Algeria (DZ): Departments (Wilaya) and Municipalities (Baladiyahs) (thanks to [Walid Yacine MAZED](https://github.com/w-mazed))
* Brazil (BR): States and Municipalities ([country request](https://github.com/chitezh/woocommerce_states_places/issues/35) - issue #35)
* Nicaragua (NI): Departments and Cities (thanks to [ahc505](https://github.com/ahc505))
* Russia (RU): States and Cities (thanks to [Sarge Madovsky](https://github.com/SargeMadovsky))
* Spain (ES): Provinces and Municipalities (thanks to [Javier Esteban](https://profiles.wordpress.org/nobnob/))
* Tunisia (TN): Governorates (thanks to [Anouar Ben Saad](https://github.com/anouarbensaad))
* Updated 2 countries:
* Chile (CL): states codes (thanks to [Luis Urrutia](https://github.com/LuisUrrutia))
* Guatemala (GT): missing municipalities (thanks to [macnomo](https://github.com/macnomo))
* Added localization to "State" and "City" field labels
* Tested up to WooCommerce 4.0.1
* 1.2.1 - March 18, 2020
* Added two new countries:
* Panama (PA): Provinces, Districts and Corregimientos
* Venezuela (VE): States and Municipalities (with their capitals)
* Invert the order of State and City fields to have more sense with the steps of form.
* Fix text domain in plugin header comment (states-cities-and-places-for-woocommerce).
* Fix some typos and strings without translation functions.
* 1.2.0
* 07/02/2019 Add Guatemala
* 1.1.1
* 28/08/2018 Update Chilean states and cities (16 states, no numbers).
* 1.1.0
* 09/07/2017 Add Chilean states
* 1.0.2
* 10/08/2016 Change author name.
* 1.0.1
* 10/08/2016 Update readme.
* 1.0.0
* 15/07/2016 First release.
* 1.2.0 - February 07, 2019
* Added a new country: Guatemala (GT)
* 1.1.1 - August 28, 2018
* Updated Chilean states and cities (16 states, no numbers).
* 1.1.0 - July 09, 2017
* Added a new country: Chile (CL)
* 1.0.2 - August 11, 2016
* Change author name.
* 1.0.1 - August 10, 2016
* Updated README file.
* 1.0 - August 10, 2016
* First release.
121 changes: 121 additions & 0 deletions tags/1.2.2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
=== States, Cities, and Places for Woocommerce ===
Contributors: chitezh, luisurrutiaf, yordansoares, nobnob
Donate link: https://github.com/chitezh
Tags: woocommerce, states, cities, local government, dropdown, city, city select, cities select, city dropdown, cities dropdown, woocommerce city, woocommerce cities, Nigeria, Chile
Requires at least: 4.7.14
Tested up to: 5.4
Requires PHP: 7.0
Stable tag: 1.2.2
WC requires at least: 3.0.x
WC tested up to: 4.0.1
License: GPLv2 or later
License URI: [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)

Wordpress plugin that shows dropdowns for State and City Select for woocomerce

== Description ==

This WooCommerce plugin transforms the text input for states, the city or town. With this plugin you can provide a list of states and cities to be shown as a select dropdown.

This will be shown in checkout pages, edit addresses pages, shipping calculator, etc.

= Supported Countries =
* Algeria
* Brazil
* Chile
* Guatemala
* Nicaragua
* Nigeria
* Panama
* Russia
* Spain
* Tunisia
* Venezuela

== Installation ==

= Minimum Requirements =

WordPress 4.0 or greater
Woocommerce 2.2 or greater
PHP version 5.2.4 or greater
MySQL version 5.0 or greater

= Automatic installation =

Automatic installation is the easiest option as WordPress handles the file transfers itself and you don’t need to leave your web browser. To do an automatic install of WooCommerce, log in to your WordPress dashboard, navigate to the Plugins menu and click `Add New`.

Search for `States, Cities, and Places for Woocommerce`, install and activate

= Manual installation =

[See wordpress codex](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation)

= Updating =

Automatic updates should work like a charm; as is the best practice, back up should be undertaken before updates.

If on the off-chance you do encounter issues with the shop/category pages after an update you simply need to flush the permalinks by going to WordPress > Settings > Permalinks and hitting 'save'. That should return things to normal.

== Frequently Asked Questions ==

= How do I report bugs? =
Kindly create an issue stating the bug and how you caught it [https://github.com/chitezh/woocommerce_states_places/issues/new](https://github.com/chitezh/woocommerce_states_places/issues/new).

= Can I suggest a new place or location? =
Yes, you can always suggest or request new locations by creating an issue in [chitezh/woocommerce_states_places](https://github.com/chitezh/woocommerce_states_places/issues/new). Please refer to the [Country Codes](https://github.com/woocommerce/woocommerce/blob/master/i18n/countries.php) using by WooCommerce.

= How do I contribute to the project? =
You extend the plugin to cover countries, states and places. we accept pull requests. Fork the repo and make changes to /trunk. Consider reading [wordpress faq](https://wordpress.org/plugins/about/faq/) to further understand wordpress svn file structure.

Pull Requests

Document any change in behaviour - Make sure the README.md and any other relevant documentation are kept up-to-date.

Consider our release cycle - We try to follow SemVer v2.0.0. Randomly breaking public APIs is not an option.

Create feature branches - Don't ask us to pull from your master branch.

One pull request per feature - If you want to do more than one thing, send multiple pull requests.

Send coherent history - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

== Screenshots ==
1. States dropdown.
2. States dropdown on search.
3. Cities dropdown on search.
4. Selected state and city.

== Changelog ==
= 1.2.2 - March 22, 2020 =
* Added six new countries:
* Algeria (DZ): Departments (Wilaya) and Municipalities (Baladiyahs) (thanks to [Walid Yacine MAZED](https://github.com/w-mazed))
* Brazil (BR): States and Municipalities ([country request](https://github.com/chitezh/woocommerce_states_places/issues/35) - issue #35)
* Nicaragua (NI): Departments and Cities (thanks to [ahc505](https://github.com/ahc505))
* Russia (RU): States and Cities (thanks to [Sarge Madovsky](https://github.com/SargeMadovsky))
* Spain (ES): Provinces and Municipalities (thanks to [Javier Esteban](https://profiles.wordpress.org/nobnob/))
* Tunisia (TN): Governorates (thanks to [Anouar Ben Saad](https://github.com/anouarbensaad))
* Updated 2 countries:
* Chile (CL): states codes (thanks to [Luis Urrutia](https://github.com/LuisUrrutia))
* Guatemala (GT): missing municipalities (thanks to [macnomo](https://github.com/macnomo))
* Added localization to "State" and "City" field labels
* Tested up to WooCommerce 4.0.1
= 1.2.1 - March 18, 2020 =
* Added two new countries:
* Panama (PA): Provinces, Districts and Corregimientos
* Venezuela (VE): States and Municipalities (with their capitals)
* Invert the order of State and City fields to have more sense with the steps of form.
* Fix text domain in plugin header comment (states-cities-and-places-for-woocommerce).
* Fix some typos and strings without translation functions.
= 1.2.0 - February 07, 2019 =
* Added a new country: Guatemala (GT)
= 1.1.1 - August 28, 2018 =
* Updated Chilean states and cities (16 states, no numbers).
= 1.1.0 - July 09, 2017 =
* Added a new country: Chile (CL)
= 1.0.2 - August 11, 2016 =
* Change author name.
= 1.0.1 - August 10, 2016 =
* Updated README file.
= 1.0 - August 10, 2016 =
* First release.
180 changes: 180 additions & 0 deletions tags/1.2.2/js/place-select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
jQuery( function($) {

// wc_city_select_params is required to continue, ensure the object exists
// wc_country_select_params is used for select2 texts. This one is added by WC
if ( typeof wc_country_select_params === 'undefined' || typeof wc_city_select_params === 'undefined' ) {
return false;
}

function getEnhancedSelectFormatString() {
var formatString = {
formatMatches: function( matches ) {
if ( 1 === matches ) {
return wc_country_select_params.i18n_matches_1;
}

return wc_country_select_params.i18n_matches_n.replace( '%qty%', matches );
},
formatNoMatches: function() {
return wc_country_select_params.i18n_no_matches;
},
formatAjaxError: function() {
return wc_country_select_params.i18n_ajax_error;
},
formatInputTooShort: function( input, min ) {
var number = min - input.length;

if ( 1 === number ) {
return wc_country_select_params.i18n_input_too_short_1;
}

return wc_country_select_params.i18n_input_too_short_n.replace( '%qty%', number );
},
formatInputTooLong: function( input, max ) {
var number = input.length - max;

if ( 1 === number ) {
return wc_country_select_params.i18n_input_too_long_1;
}

return wc_country_select_params.i18n_input_too_long_n.replace( '%qty%', number );
},
formatSelectionTooBig: function( limit ) {
if ( 1 === limit ) {
return wc_country_select_params.i18n_selection_too_long_1;
}

return wc_country_select_params.i18n_selection_too_long_n.replace( '%qty%', limit );
},
formatLoadMore: function() {
return wc_country_select_params.i18n_load_more;
},
formatSearching: function() {
return wc_country_select_params.i18n_searching;
}
};

return formatString;
}

// Select2 Enhancement if it exists
if ( $().select2 ) {
var wc_city_select_select2 = function() {
$( 'select.city_select:visible' ).each( function() {
var select2_args = $.extend({
placeholderOption: 'first',
width: '100%'
}, getEnhancedSelectFormatString() );

$( this ).select2( select2_args );
});
};

wc_city_select_select2();

$( document.body ).bind( 'city_to_select', function() {
wc_city_select_select2();
});
}

/* City select boxes */
var cities_json = wc_city_select_params.cities.replace( /"/g, '"' );
var cities = $.parseJSON( cities_json );

$( 'body' ).on( 'country_to_state_changing', function(e, country, $container) {
var $statebox = $container.find( '#billing_state, #shipping_state, #calc_shipping_state' );
var state = $statebox.val();
$( document.body ).trigger( 'state_changing', [country, state, $container ] );
});

$( 'body' ).on( 'change', 'select.state_select, #calc_shipping_state', function() {
var $container = $( this ).closest( 'div' );
var country = $container.find( '#billing_country, #shipping_country, #calc_shipping_country' ).val();
var state = $( this ).val();

$( document.body ).trigger( 'state_changing', [country, state, $container ] );
});

$( 'body' ).on( 'state_changing', function(e, country, state, $container) {
var $citybox = $container.find( '#billing_city, #shipping_city, #calc_shipping_city' );

if ( cities[ country ] ) {
/* if the country has no states */
if( cities[country] instanceof Array) {
cityToSelect( $citybox, cities[ country ] );
} else if ( state ) {
if ( cities[ country ][ state ] ) {
cityToSelect( $citybox, cities[ country ][ state ] );
} else {
cityToInput( $citybox );
}
} else {
disableCity( $citybox );
}
} else {
cityToInput( $citybox );
}
});

/* Ajax replaces .cart_totals (child of .cart-collaterals) on shipping calculator */
if ( $( '.cart-collaterals' ).length && $( '#calc_shipping_state' ).length ) {
var calc_observer = new MutationObserver( function() {
$( '#calc_shipping_state' ).change();
});
calc_observer.observe( document.querySelector( '.cart-collaterals' ), { childList: true });
}

function cityToInput( $citybox ) {
if ( $citybox.is('input') ) {
$citybox.prop( 'disabled', false );
return;
}

var input_name = $citybox.attr( 'name' );
var input_id = $citybox.attr( 'id' );
var placeholder = $citybox.attr( 'placeholder' );

$citybox.parent().find( '.select2-container' ).remove();

$citybox.replaceWith( '<input type="text" class="input-text" name="' + input_name + '" id="' + input_id + '" placeholder="' + placeholder + '" />' );
}

function disableCity( $citybox ) {
$citybox.val( '' ).change();
$citybox.prop( 'disabled', true );
}

function cityToSelect( $citybox, current_cities ) {
var value = $citybox.val();

if ( $citybox.is('input') ) {
var input_name = $citybox.attr( 'name' );
var input_id = $citybox.attr( 'id' );
var placeholder = $citybox.attr( 'placeholder' );

$citybox.replaceWith( '<select name="' + input_name + '" id="' + input_id + '" class="city_select" placeholder="' + placeholder + '"></select>' );
//we have to assign the new object, because of replaceWith
$citybox = $('#'+input_id);
} else {
$citybox.prop( 'disabled', false );
}

var options = '';
for( var index in current_cities ) {
if ( current_cities.hasOwnProperty( index ) ) {
var cityName = current_cities[ index ];
options = options + '<option value="' + cityName + '">' + cityName + '</option>';
}
}

$citybox.html( '<option value="">' + wc_city_select_params.i18n_select_city_text + '</option>' + options );

if ( $('option[value="'+value+'"]', $citybox).length ) {
$citybox.val( value ).change();
} else {
$citybox.val( '' ).change();
}

$( document.body ).trigger( 'city_to_select' );
}
});
Loading