Merge pull request #27048 from vallter2/postcode-bih
Add postcode validation for Bosnia and Herzegovina
This commit is contained in:
commit
0b0595ab4c
|
@ -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',
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue