function taager_get_url($api_name, $options = null) {
  $taager_url = TAAGER_URL;

  // 1. جلب الدولة المختارة من إعدادات الووردبريس
  $selected_country = get_option('ta_selected_country'); 
  
  // 2. تحويل اسم الدولة إلى الكود المطلوب في الـ API
  $country_code = 'EGY'; // الافتراضي مصر
  
  if (strpos($selected_country, 'السعودية') !== false || $selected_country == 'KSA') {
      $country_code = 'SAU';
  } elseif (strpos($selected_country, 'الإمارات') !== false || $selected_country == 'UAE') {
      $country_code = 'ARE';
  } elseif (strpos($selected_country, 'العراق') !== false) {
      $country_code = 'IRQ';
  }

  switch ($api_name) {
    case 'CATEGORIES':
      return "$taager_url/commercial-categories?country=$country_code&topLevel=false";
    case 'PRODUCTS':
      $default_params = ['country' => $country_code];
      $query_params = http_build_query(array_merge($default_params, $options ?: []));
      return "$taager_url/products?$query_params";
    case 'ORDERS':
      if (isset($options['orderId'])) {
        return "$taager_url/orders?orderId=" . urlencode($options['orderId']);
      }
      return "$taager_url/orders";
    case 'PROVINCES':
      return "$taager_url/countries/$country_code/provinces";
    case 'IMPORT_PRODUCTS':
    case 'PRODUCT':
      $default_params = ['country' => $country_code];
      $query_params = http_build_query(array_merge($default_params, $options ?: []));
      return "$taager_url/products?$query_params";
    case 'PROVINCES_ZONES_DISTRICTS':
      return "$taager_url/countries/$country_code/provinces";
    default:
      return "";
  }
}<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//sa.afarkosh.com/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://sa.afarkosh.com/page-sitemap.xml</loc>
		<lastmod>2025-06-13T00:04:42+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://sa.afarkosh.com/product-sitemap.xml</loc>
		<lastmod>2025-07-02T14:28:31+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Rank Math SEO Plugin (c) Rank Math - rankmath.com -->