} else {
$replace['{district}'] = null;
}
return $replace;
}
function my_account_my_address_formatted_address( $args, $customer_id, $name ) {
$args['district'] = get_user_meta( $customer_id, $name . '_district', true );
return $args;
}
public function checkout_get_value( $value, $key ) {
if ( ! in_array( $key, [ 'billing_district', 'shipping_district' ] ) ) {
return $value;
}
return WC()->session->get( $key, 0 );
}
// Functions
public function types() {
$types = [ 'billing' ];
if ( ! wc_ship_to_billing_address_only() ) {
$types[] = 'shipping';
}
return $types;
}
public static function states() {
$states = get_transient( 'pws_states' );
if ( $states === false || count( (array) $states ) == 0 ) {
$states = get_terms( [
'taxonomy' => 'state_city',
'hide_empty' => false,
'parent' => 0,
] );
$states = wp_list_pluck( $states, 'name', 'term_id' );
uasort( $states, [ self::class, 'pws_sort_state' ] );
set_transient( 'pws_states', $states, DAY_IN_SECONDS );
}
return apply_filters( 'pws_states', $states );
}
public static function get_state( $state_id ) {
$states = PWS()->states();
return $states[ $state_id ] ?? null;
}
public static function cities( $state_id ) {
$cities = get_transient( 'pws_cities_' . $state_id );
if ( $cities === false || count( (array) $cities ) == 0 ) {
$cities = get_terms( [
'taxonomy' => 'state_city',
'hide_empty' => false,
'parent' => $state_id,
] );
if ( is_wp_error( $cities ) ) {
$cities = [];
} else {
$cities = array_column( $cities, 'name', 'term_id' );
}
set_transient( 'pws_cities_' . $state_id, $cities, DAY_IN_SECONDS );
}
return apply_filters( 'pws_cities', $cities, $state_id );
}
public static function get_city( $city_id ) {
/** @var WP_Term $city */
$city = get_term( $city_id, 'state_city' );
return is_wp_error( $city ) || is_null( $city ) ? null : $city->name;
}
public function check_states_beside( $source, $destination ) {
if ( $source == $destination ) {
return 'in';
}
$is_beside["AE"]["AW"] = true;
$is_beside["AE"]["AR"] = true;
$is_beside["AE"]["ZA"] = true;
$is_beside["AW"]["AE"] = true;
$is_beside["AW"]["KD"] = true;
$is_beside["AW"]["ZA"] = true;
$is_beside["AR"]["AE"] = true;
$is_beside["AR"]["GI"] = true;
$is_beside["AR"]["ZA"] = true;
$is_beside["IS"]["CM"] = true;
$is_beside["IS"]["LO"] = true;
$is_beside["IS"]["KB"] = true;
$is_beside["IS"]["MK"] = true;
$is_beside["IS"]["QM"] = true;
$is_beside["IS"]["SM"] = true;
$is_beside["IS"]["KJ"] = true;
$is_beside["IS"]["YA"] = true;
$is_beside["IS"]["FA"] = true;
$is_beside["AL"]["TE"] = true;
$is_beside["AL"]["MK"] = true;
$is_beside["AL"]["QZ"] = true;
$is_beside["AL"]["MN"] = true;
$is_beside["IL"]["BK"] = true;
$is_beside["IL"]["LO"] = true;
$is_beside["IL"]["KZ"] = true;
$is_beside["BU"]["KB"] = true;
$is_beside["BU"]["KZ"] = true;
$is_beside["BU"]["FA"] = true;
$is_beside["BU"]["HG"] = true;
$is_beside["TE"]["AL"] = true;
$is_beside["TE"]["MK"] = true;
$is_beside["TE"]["QM"] = true;
$is_beside["TE"]["MN"] = true;
$is_beside["TE"]["SM"] = true;
$is_beside["CM"]["KB"] = true;
$is_beside["CM"]["KZ"] = true;
$is_beside["CM"]["LO"] = true;
$is_beside["CM"]["IS"] = true;
$is_beside["KJ"]["SB"] = true;
$is_beside["KJ"]["KE"] = true;
$is_beside["KJ"]["YA"] = true;
$is_beside["KJ"]["IS"] = true;
$is_beside["KJ"]["SM"] = true;
$is_beside["KJ"]["KV"] = true;
$is_beside["KV"]["KJ"] = true;
$is_beside["KV"]["KS"] = true;
$is_beside["KV"]["SM"] = true;
$is_beside["KS"]["KV"] = true;
$is_beside["KS"]["GO"] = true;
$is_beside["KS"]["SM"] = true;
$is_beside["KZ"]["IL"] = true;
$is_beside["KZ"]["BU"] = true;
$is_beside["KZ"]["LO"] = true;
$is_beside["KZ"]["KB"] = true;
$is_beside["KZ"]["CM"] = true;
$is_beside["ZA"]["GI"] = true;
$is_beside["ZA"]["AR"] = true;
$is_beside["ZA"]["AE"] = true;
$is_beside["ZA"]["AW"] = true;
$is_beside["ZA"]["KD"] = true;
$is_beside["ZA"]["HD"] = true;
$is_beside["ZA"]["QZ"] = true;
$is_beside["SM"]["MN"] = true;
$is_beside["SM"]["TE"] = true;
$is_beside["SM"]["QM"] = true;
$is_beside["SM"]["IS"] = true;
$is_beside["SM"]["KS"] = true;
$is_beside["SM"]["KV"] = true;
$is_beside["SM"]["KJ"] = true;
$is_beside["SB"]["KJ"] = true;
$is_beside["SB"]["KE"] = true;
$is_beside["SB"]["HG"] = true;
$is_beside["FA"]["IS"] = true;
$is_beside["FA"]["YA"] = true;
$is_beside["FA"]["BU"] = true;
$is_beside["FA"]["HG"] = true;
$is_beside["FA"]["KB"] = true;
$is_beside["FA"]["KE"] = true;
$is_beside["QZ"]["ZA"] = true;
$is_beside["QZ"]["HD"] = true;
$is_beside["QZ"]["MK"] = true;
$is_beside["QZ"]["AL"] = true;
$is_beside["QZ"]["MN"] = true;
$is_beside["QZ"]["GI"] = true;
$is_beside["QM"]["TE"] = true;
$is_beside["QM"]["MK"] = true;
$is_beside["QM"]["SM"] = true;
$is_beside["QM"]["IS"] = true;
$is_beside["KD"]["AW"] = true;
$is_beside["KD"]["BK"] = true;
$is_beside["KD"]["HD"] = true;
$is_beside["KD"]["ZA"] = true;
$is_beside["KE"]["YA"] = true;
$is_beside["KE"]["FA"] = true;
$is_beside["KE"]["HG"] = true;
$is_beside["KE"]["SB"] = true;
$is_beside["KE"]["KJ"] = true;
$is_beside["BK"]["KD"] = true;
$is_beside["BK"]["HD"] = true;
$is_beside["BK"]["LO"] = true;
$is_beside["BK"]["IL"] = true;
$is_beside["KB"]["CM"] = true;
$is_beside["KB"]["KZ"] = true;
$is_beside["KB"]["BU"] = true;
$is_beside["KB"]["FA"] = true;
$is_beside["KB"]["IS"] = true;
$is_beside["GO"]["MN"] = true;
$is_beside["GO"]["KS"] = true;
$is_beside["GO"]["SM"] = true;
$is_beside["GI"]["MN"] = true;
$is_beside["GI"]["AR"] = true;
$is_beside["GI"]["ZA"] = true;
$is_beside["GI"]["QZ"] = true;
$is_beside["LO"]["IL"] = true;
$is_beside["LO"]["BK"] = true;
$is_beside["LO"]["HD"] = true;
$is_beside["LO"]["MK"] = true;
$is_beside["LO"]["IS"] = true;
$is_beside["LO"]["CM"] = true;
$is_beside["LO"]["KZ"] = true;
$is_beside["MN"]["GO"] = true;
$is_beside["MN"]["SM"] = true;
$is_beside["MN"]["TE"] = true;
$is_beside["MN"]["AL"] = true;
$is_beside["MN"]["IS"] = true;
$is_beside["MN"]["QZ"] = true;
$is_beside["MN"]["GI"] = true;
$is_beside["MK"]["IS"] = true;
$is_beside["MK"]["QM"] = true;
$is_beside["MK"]["TE"] = true;
$is_beside["MK"]["AL"] = true;
$is_beside["MK"]["LO"] = true;
$is_beside["MK"]["QZ"] = true;
$is_beside["MK"]["HD"] = true;
$is_beside["HG"]["BU"] = true;
$is_beside["HG"]["FA"] = true;
$is_beside["HG"]["KE"] = true;
$is_beside["HG"]["SB"] = true;
$is_beside["HD"]["BK"] = true;
$is_beside["HD"]["LO"] = true;
$is_beside["HD"]["KD"] = true;
$is_beside["HD"]["MK"] = true;
$is_beside["HD"]["QZ"] = true;
$is_beside["HD"]["ZA"] = true;
$is_beside["YA"]["FA"] = true;
$is_beside["YA"]["KE"] = true;
$is_beside["YA"]["KJ"] = true;
$source = get_term( $source, 'state_city' );
$destination = get_term( $destination, 'state_city' );
if ( is_wp_error( $source ) || is_wp_error( $destination ) ) {
return false;
}
$source = $source->slug ?? null;
$destination = $destination->slug ?? null;
return isset( $is_beside[ strtoupper( $source ) ][ strtoupper( $destination ) ] ) && $is_beside[ strtoupper( $source ) ][ strtoupper( $destination ) ] === true ? 'beside' : 'out';
}
public function convert_currency( $price ) {
switch ( get_woocommerce_currency() ) {
case 'IRT':
$price /= 10;
break;
case 'IRHR':
$price /= 1000;
break;
case 'IRHT':
$price /= 10000;
break;
}
return ceil( $price );
}
public function get_term_option( $term_id ): array {
$option = get_option( 'nabik_taxonomy_' . $term_id, [] );
return apply_filters( 'pws_get_term_option', $option, $term_id );
}
public function set_term_option( $term_id, array $option ) {
$option = apply_filters( 'pws_set_term_option', $option, $term_id );
update_option( 'nabik_taxonomy_' . $term_id, $option );
}
public function delete_term_option( $term_id ) {
delete_option( 'nabik_taxonomy_' . $term_id );
}
public function get_terms_option( $term_id ) {
$options = wp_cache_get( 'get_terms_option_' . $term_id, 'pws' );
if ( false !== $options ) {
return $options;
}
$ancestors = get_ancestors( $term_id, 'state_city' );
if ( empty( $ancestors ) ) {
return [];
}
array_unshift( $ancestors, $term_id );
$options = array_map( [ $this, 'get_term_option' ], $ancestors );
wp_cache_set( 'get_terms_option_' . $term_id, $options, 'pws' );
return $options;
}
public static function get_option( string $option_name, $default = null ) {
[ $section, $option ] = explode( '.', $option_name );
$options = get_option( 'pws_' . $section, [] );
if ( isset( $options[ $option ] ) ) {
return $options[ $option ];
}
return $default;
}
public static function set_option( string $option_name, $value ) {
[ $section, $option ] = explode( '.', $option_name );
$options = get_option( 'pws_' . $section, [] );
$options = empty( $options ) ? [] : $options;
$options[ $option ] = $value;
update_option( 'pws_' . $section, $options );
}
public function log( ...$params ) {
$log = '';
$date = wp_date( 'Y-m-d' );
if ( defined( 'WC_LOG_DIR' ) ) {
$log_file = WC_LOG_DIR . "pws-{$date}.log";
} else {
$log_file = WP_CONTENT_DIR . "pws-{$date}.log";
}
foreach ( $params as $message ) {
$log .= wp_date( '[Y-m-d H:i:s] ' );
if ( is_array( $message ) || is_object( $message ) ) {
$log .= print_r( $message, true );
} elseif ( is_bool( $message ) ) {
$log .= ( $message ? 'true' : 'false' );
} else {
$log .= $message;
}
$log .= PHP_EOL;
}
file_put_contents( $log_file, $log, FILE_APPEND );
}
public static function pws_sort_state( $a, $b ) {
if ( $a == $b ) {
return 0;
}
$states = [
'آذربایجان شرقی',
'آذربایجان غربی',
'اردبیل',
'اصفهان',
'البرز',
'ایلام',
'بوشهر',
'تهران',
'چهارمحال و بختیاری',
'خراسان جنوبی',
'خراسان رضوی',
'خراسان شمالی',
'خوزستان',
'زنجان',
'سمنان',
'سیستان و بلوچستان',
'فارس',
'قزوین',
'قم',
'کردستان',
'کرمان',
'کرمانشاه',
'کهگیلویه و بویراحمد',
'گلستان',
'گیلان',
'لرستان',
'مازندران',
'مرکزی',
'هرمزگان',
'همدان',
'یزد',
];
$a = str_replace( [ 'ي', 'ك', 'ة' ], [ 'ی', 'ک', 'ه' ], $a );
$b = str_replace( [ 'ي', 'ك', 'ة' ], [ 'ی', 'ک', 'ه' ], $b );
$a_key = array_search( trim( $a ), $states );
$b_key = array_search( trim( $b ), $states );
return $a_key < $b_key ? - 1 : 1;
}
public function pws_pro_url( $source ): string {
return 'https://yun.ir/pws-pro?utm_source=' . esc_attr( $source );
}
}
Fatal error: Uncaught Error: Class 'PWS_Core' not found in /home/arasetne/public_html/wp-content/plugins/persian-woocommerce-shipping/includes/class-tapin.php:11
Stack trace:
#0 /home/arasetne/public_html/wp-content/plugins/persian-woocommerce-shipping/woocommerce-shipping.php(46): include()
#1 /home/arasetne/public_html/wp-includes/class-wp-hook.php(324): {closure}('')
#2 /home/arasetne/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#3 /home/arasetne/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#4 /home/arasetne/public_html/wp-content/plugins/woocommerce/includes/class-woocommerce.php(205): do_action('woocommerce_loa...')
#5 /home/arasetne/public_html/wp-includes/class-wp-hook.php(324): WooCommerce->on_plugins_loaded('')
#6 /home/arasetne/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#7 /home/arasetne/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#8 /home/arasetne/public_html/wp-settings.php(550): do_acti in /home/arasetne/public_html/wp-content/plugins/persian-woocommerce-shipping/includes/class-tapin.php on line 11