- سورمه ایطوسیپرداخت درب محل
موجود در انبار٪۸۴۰,۰۰۰ تومان۱۴
۹۸۰,۰۰۰ تومان
function wc_currency_get_prices() { $api_all = trim( (string) get_option('wc_currency_api_all', '') ); $symbols = explode(',', get_option('wc_currency_symbols', 'USD,AED')); $minutes = max( 1, intval( get_option('wc_currency_cache_minutes', 30 ) ) ); $cache_key = 'wc_currency_prices_cache'; $cached = get_transient($cache_key); if ( $cached && is_array($cached) ) { return $cached; } $prices = []; $resp = wp_remote_get( $api_all, array( 'timeout' => 15 ) ); if ( is_wp_error($resp) ) { error_log('API ERROR: ' . $resp->get_error_message()); return []; } // لاگ گرفتن از بدنه خام پاسخ $body = wp_remote_retrieve_body($resp); error_log('RAW BODY: ' . $body); // لاگ گرفتن از داده بعد از json_decode $data = json_decode($body, true); error_log('DECODED DATA: ' . print_r($data, true)); if ( isset($data['symbol']) ) { // حالت آبجکت تکی $sym = strtoupper($data['symbol']); $prices[strtolower($sym)] = $data['price'] . ' ' . $data['unit']; } elseif ( is_array($data) ) { // حالت آرایه foreach ($symbols as $sym) { $sym = strtoupper(trim($sym)); $found = 'N/A'; foreach ($data as $item) { if ( isset($item['symbol']) && strtoupper($item['symbol']) === $sym ) { $found = $item['price'] . ' ' . $item['unit']; break; } } $prices[strtolower($sym)] = $found; } } // لاگ گرفتن از نتیجه نهایی error_log('FINAL PRICES: ' . print_r($prices, true)); set_transient($cache_key, $prices, $minutes * MINUTE_IN_SECONDS); return $prices; }

۱۴
۹۸۰,۰۰۰ تومان
