public static function send_via_zre($order){
    $s = self::settings();
    if (!$s['api_key'] || !$s['tenant_id']) {
        return ['success' => false, 'message' => 'أكمل إعدادات ZR أولاً'];
    }

    if (!get_option(self::OPT_TERR, [])) {
        return ['success' => false, 'message' => 'زامن المناطق والمكاتب أولاً'];
    }

    $raw_wilaya  = $order->get_billing_state();
    $raw_commune = $order->get_meta('_billing_commune') ?: $order->get_billing_city();
    $wilaya_name = self::resolve_wilaya($raw_wilaya);

    $matched = self::match_territory($wilaya_name, $raw_commune);
    if (!$matched['success']) return $matched;

    $delivery_meta = self::get_delivery_type($order);
    $is_office = ($delivery_meta === 'OUI');
    $delivery_type = $is_office ? 'pickup-point' : 'home';

    $hub_id = null;
    if ($is_office) {
        $office = (string) $order->get_meta('_shipping_office');

        if (trim($office) === '') {
            $office = self::get_hub_name_by_commune($raw_commune);
            if ($office !== '') {
                $order->update_meta_data('_shipping_office', $office);
                $order->save();
            }
        }

        if ($office !== '') {
            $hub_id = self::match_hub($office, $raw_commune, $wilaya_name);
        }

        if (!$hub_id) {
            return ['success' => false, 'message' => 'لم يتم العثور على مكتب مطابق لاسم البلدية'];
        }
    }

    $items = $order->get_items();
    $product_name = !empty($items) ? reset($items)->get_name() : 'Colis';

    $payload = [
        'customer' => [
            'customerId' => wp_generate_uuid4(),
            'name' => trim($order->get_billing_first_name() . ' ' . $order->get_billing_last_name()) ?: 'Client',
            'phone' => ['number1' => self::format_phone($order->get_billing_phone())]
        ],
        'deliveryAddress' => [
            'street' => $order->get_billing_address_1() ?: 'Adresse non spécifiée',
            'cityTerritoryId' => $matched['city_id'],
            'districtTerritoryId' => $matched['district_id'],
            'country' => 'algeria'
        ],
        'orderedProducts' => [[
            'productName' => $product_name,
            'unitPrice' => (float)$order->get_total(),
            'quantity' => max(1, count($items)),
            'stockType' => $s['default_stock'],
            'weight' => (float)$s['default_weight']
        ]],
        'amount' => (float)$order->get_total(),
        'description' => $product_name,
        'deliveryType' => $delivery_type
    ];

    if ($hub_id) {
        $payload['hubId'] = $hub_id;
    }

    $res = self::request('POST', '/parcels', $payload);
    if (!$res['success']) return $res;

    $parcel_id = $res['body']['id'] ?? '';
    if (!$parcel_id) return ['success' => false, 'message' => 'لم يصل Parcel ID'];

    $tracking = $res['body']['trackingNumber'] ?? $parcel_id;
    $order->update_meta_data('_zre_tracking', $tracking);
    $order->update_meta_data('_sos_last_state', 'تم الإرسال إلى ZR');
    $order->set_status('sos-zr');
    $order->add_order_note('تم الإرسال إلى ZR. Tracking: ' . $tracking);
    $order->save();

    return ['success' => true, 'tracking' => $tracking];
}<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://natura-monocoat.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://natura-monocoat.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://natura-monocoat.com/wp-sitemap-posts-product-1.xml</loc></sitemap><sitemap><loc>https://natura-monocoat.com/wp-sitemap-taxonomies-product_cat-1.xml</loc></sitemap><sitemap><loc>https://natura-monocoat.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
