Made wc_get_wildcard_postcodes return the orignal postcode plus * since wildcards should match empty strings too.

Fixes #12016
This commit is contained in:
Mike Jolley 2016-10-12 11:52:39 +01:00
parent 3e11e168cd
commit a7e531e26d
2 changed files with 10 additions and 6 deletions

View File

@ -1245,13 +1245,16 @@ function wc_help_tip( $tip, $allow_html = false ) {
* @return string[]
*/
function wc_get_wildcard_postcodes( $postcode, $country = '' ) {
$postcodes = array( $postcode );
$postcode = wc_format_postcode( $postcode, $country );
$postcodes[] = $postcode;
$postcode_length = strlen( $postcode );
$formatted_postcode = wc_format_postcode( $postcode, $country );
$length = strlen( $formatted_postcode );
$postcodes = array(
$postcode,
$formatted_postcode,
$formatted_postcode . '*',
);
for ( $i = 0; $i < $postcode_length; $i ++ ) {
$postcodes[] = substr( $postcode, 0, ( $i + 1 ) * -1 ) . '*';
for ( $i = 0; $i < $length; $i ++ ) {
$postcodes[] = substr( $formatted_postcode, 0, ( $i + 1 ) * -1 ) . '*';
}
return $postcodes;

View File

@ -181,6 +181,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woocommerce/wo
* When deleting a tax rate class, remove it's tax rates.
* Made the store notice dismissible.
* Improved the zone setup flow.
* Made wc_get_wildcard_postcodes return the orignal postcode plus * since wildcards should match empty strings too.
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce/master/CHANGELOG.txt).