if (!function_exists('tesim_sync_packages')) { function tesim_sync_packages() { if (!class_exists('TESIM_API')) { tesim_log_write('TESIM_API client missing.'); return 0; } // FIXED: use correct endpoint $resp = TESIM_API::request('GET', 'products'); if (is_wp_error($resp)) { tesim_log_write('Sync error: ' . $resp->get_error_message()); return 0; } // eSIMAccess returns { data: [...] } $items = $resp['data'] ?? []; if (!is_array($items)) { tesim_log_write('Sync warning: invalid data structure.'); return 0; } // Normalize data $normalized = []; foreach ($items as $it) { $normalized[] = [ 'id' => $it['id'] ?? '', 'name' => $it['name'] ?? '', 'description' => $it['description'] ?? '', 'country' => $it['region'] ?? '', 'days' => $it['validity'] ?? '', 'price' => $it['price'] ?? '', 'raw' => $it, ]; } set_transient('tesim_packages_cache', $normalized, 12 * HOUR_IN_SECONDS); tesim_log_write("Synced " . count($normalized) . " packages."); return count($normalized); } } Log In ‹ UniComms Support System — WordPress

Log In

Powered by WordPress

← Go to UniComms Support System