Merge pull request #27048 from vallter2/postcode-bih

Add postcode validation for Bosnia and Herzegovina
This commit is contained in:
Ron Rennick 2020-08-10 16:24:06 -03:00 committed by GitHub
commit 0b0595ab4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 1 deletions

View File

@ -27,6 +27,15 @@ return array(
'weight_unit' => 'kg',
'dimension_unit' => 'cm',
),
'BA' => array(
'currency_code' => 'BAM',
'currency_pos' => 'right_space',
'thousand_sep' => '.',
'decimal_sep' => ',',
'num_decimals' => 2,
'weight_unit' => 'kg',
'dimension_unit' => 'cm',
),
'BD' => array(
'currency_code' => 'BDT',
'currency_pos' => 'left',

View File

@ -820,6 +820,16 @@ class WC_Countries {
'required' => false,
),
),
'BA' => array(
'postcode' => array(
'priority' => 65,
),
'state' => array(
'label' => __( 'Canton', 'woocommerce' ),
'required' => false,
'hidden' => true,
),
),
'BD' => array(
'postcode' => array(
'required' => false,

View File

@ -53,6 +53,9 @@ class WC_Validation {
case 'AT':
$valid = (bool) preg_match( '/^([0-9]{4})$/', $postcode );
break;
case 'BA':
$valid = (bool) preg_match( '/^([7-8]{1})([0-9]{4})$/', $postcode );
break;
case 'BR':
$valid = (bool) preg_match( '/^([0-9]{5})([-])?([0-9]{3})$/', $postcode );
break;

View File

@ -115,7 +115,15 @@ class WC_Tests_Validation extends WC_Unit_Test_Case {
array( false, WC_Validation::is_postcode( '0123', 'SI' ) ),
);
return array_merge( $it, $gb, $us, $ch, $br, $ca, $nl, $si );
$ba = array(
array( true, WC_Validation::is_postcode( '71000', 'BA' ) ),
array( true, WC_Validation::is_postcode( '78256', 'BA' ) ),
array( true, WC_Validation::is_postcode( '89240', 'BA' ) ),
array( false, WC_Validation::is_postcode( '61000', 'BA' ) ),
array( false, WC_Validation::is_postcode( '7850', 'BA' ) ),
);
return array_merge( $it, $gb, $us, $ch, $br, $ca, $nl, $si, $ba );
}
/**