تابع ووکامرسی wc_make_numeric_postcode ساخت کد پستی عددی
تابع ووکامرسی wc_make_numeric_postcode – ساخت کد پستی عددی
Syntax – سینتکس
(string) wc_make_numeric_postcode( (string) $postcode );
Parameters – پارامتر ها (1)
- 1- $postcode (string)
Usage – نحوه استفاده
if ( !function_exists( 'wc_make_numeric_postcode' ) ) { require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; } // Regular postcode $postcode = ''; // NOTICE! Understand what this does before running. $result = wc_make_numeric_postcode($postcode);
Defined – محل تعریف
/includes/wc-formatting-functions.php
function wc_make_numeric_postcode( $postcode ) { $postcode = str_replace( array( ' ', '-' ), '', $postcode ); $postcode_length = strlen( $postcode ); $letters_to_numbers = array_merge( array( 0 ), range( 'A', 'Z' ) ); $letters_to_numbers = array_flip( $letters_to_numbers ); $numeric_postcode = ''; for ( $i = 0; $i < $postcode_length; $i ++ ) { if ( is_numeric( $postcode[ $i ] ) ) { $numeric_postcode .= str_pad( $postcode[ $i ], 2, '0', STR_PAD_LEFT ); } elseif ( isset( $letters_to_numbers[ $postcode[ $i ] ] ) ) { $numeric_postcode .= str_pad( $letters_to_numbers[ $postcode[ $i ] ], 2, '0', STR_PAD_LEFT ); } else { $numeric_postcode .= '00'; } } return $numeric_postcode; }
versions – نسخه ها
از نسخه : 2.6.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر