Buyukweb
Kargo ve Lojistik Entegrasyonu: E-Ticaret Teslimat Otomasyonu

Kargo ve Lojistik Entegrasyonu: E-Ticaret Teslimat Otomasyonu

WooCommerce ve OpenCart için Türkiye'de kargo firması entegrasyonu: MNG Kargo, Yurtiçi, Aras, PTT Kargo API entegrasyonu ve otomatik sipariş takibi.

Büyükweb Teknik Ekibi4 Ocak 20267 dakika okuma

Kargo ve Lojistik Entegrasyonu: E-Ticaret Teslimat Otomasyonu

Hızlı ve güvenilir kargo, e-ticaret başarısının temel taşlarından biridir. Bu rehberde Türkiye'deki kargo firmalarının API entegrasyonunu ve lojistik otomasyonunu ele alıyoruz.

Türkiye'deki Kargo Firmaları

Firma          | API | WooCommerce | Fiyat (Desi başı)
---------------|-----|-------------|------------------
MNG Kargo      | ✓   | Eklenti     | Anlaşmalı
Yurtiçi Kargo  | ✓   | Eklenti     | Anlaşmalı
Aras Kargo     | ✓   | Eklenti     | Anlaşmalı
PTT Kargo      | ✓   | Eklenti     | Sabit tarife
Sürat Kargo    | ✓   | Eklenti     | Anlaşmalı
HepsiJet       | ✓   | Eklenti     | Hepsiburada bağlı
Trendyol Express| ✓  | Trendyol bağlı| Platform bağlı

MNG Kargo Entegrasyonu (WooCommerce)

<?php
// MNG Kargo API Entegrasyonu
class MNGKargoAPI {
    private $username;
    private $password;
    private $customerCode;
    private $apiUrl = 'https://api.mngkargo.com.tr/';

    public function __construct($username, $password, $customerCode) {
        $this->username = $username;
        $this->password = $password;
        $this->customerCode = $customerCode;
    }

    public function createShipment($orderData) {
        $body = [
            'CUSTOMER_CODE' => $this->customerCode,
            'SHIPMENT_ORDER_TYPE_CODE' => '1',
            'SENDER_NAME' => $orderData['sender']['name'],
            'SENDER_ADDRESS' => $orderData['sender']['address'],
            'SENDER_CITY' => $orderData['sender']['city'],
            'RECEIVER_NAME' => $orderData['receiver']['name'],
            'RECEIVER_ADDRESS' => $orderData['receiver']['address'],
            'RECEIVER_CITY' => $orderData['receiver']['city'],
            'RECEIVER_PHONE' => $orderData['receiver']['phone'],
            'DESI' => $orderData['desi'],
            'ORDER_NUMBER' => $orderData['order_number'],
            'DESCRIPTION' => $orderData['description'],
        ];

        $response = wp_remote_post(
            $this->apiUrl . 'shipment/create',
            [
                'headers' => [
                    'Authorization' => 'Basic ' . base64_encode($this->username . ':' . $this->password),
                    'Content-Type' => 'application/json',
                ],
                'body' => json_encode($body),
                'timeout' => 30,
            ]
        );

        if (is_wp_error($response)) {
            return false;
        }

        return json_decode(wp_remote_retrieve_body($response), true);
    }

    public function trackShipment($trackingNumber) {
        $response = wp_remote_get(
            $this->apiUrl . 'shipment/track/' . $trackingNumber,
            [
                'headers' => [
                    'Authorization' => 'Basic ' . base64_encode($this->username . ':' . $this->password),
                ],
            ]
        );

        return json_decode(wp_remote_retrieve_body($response), true);
    }
}

// WooCommerce sipariş tamamlandığında otomatik kargo oluştur
add_action('woocommerce_order_status_processing', 'create_cargo_shipment');

function create_cargo_shipment($order_id) {
    $order = wc_get_order($order_id);

    $mng = new MNGKargoAPI(
        get_option('mng_username'),
        get_option('mng_password'),
        get_option('mng_customer_code')
    );

    $result = $mng->createShipment([
        'sender' => [
            'name'    => 'MagazaNız',
            'address' => 'Depo Adres',
            'city'    => 'İstanbul',
        ],
        'receiver' => [
            'name'    => $order->get_shipping_first_name() . ' ' . $order->get_shipping_last_name(),
            'address' => $order->get_shipping_address_1(),
            'city'    => $order->get_shipping_city(),
            'phone'   => $order->get_billing_phone(),
        ],
        'desi'         => calculate_order_desi($order),
        'order_number' => $order->get_order_number(),
        'description'  => 'Sipariş #' . $order->get_order_number(),
    ]);

    if ($result && isset($result['TRACKING_NUMBER'])) {
        $order->update_meta_data('_tracking_number', $result['TRACKING_NUMBER']);
        $order->update_meta_data('_cargo_company', 'MNG');
        $order->save();

        $order->add_order_note('MNG Kargo takip: ' . $result['TRACKING_NUMBER']);
    }
}

Desi Hesaplama

function calculate_order_desi($order) {
    $total_desi = 0;

    foreach ($order->get_items() as $item) {
        $product = $item->get_product();
        $qty = $item->get_quantity();

        $weight = $product->get_weight(); // kg
        $length = $product->get_length(); // cm
        $width = $product->get_width();   // cm
        $height = $product->get_height(); // cm

        // Desi = (En x Boy x Yükseklik) / 3000
        $volumetric_desi = ($length * $width * $height) / 3000;

        // Ağırlık kg cinsinden
        $weight_desi = $weight;

        // Büyük olan desi hesaba katılır
        $desi = max($volumetric_desi, $weight_desi);
        $total_desi += $desi * $qty;
    }

    return ceil($total_desi); // Yukarı yuvarla
}

Webhook ile Kargo Durum Güncelleme

// Kargo firması webhook endpoint'i
add_action('rest_api_init', function() {
    register_rest_route('magazaniz/v1', '/cargo-webhook', [
        'methods'  => 'POST',
        'callback' => 'handle_cargo_webhook',
        'permission_callback' => '__return_true',
    ]);
});

function handle_cargo_webhook($request) {
    $data = $request->get_json_params();

    $tracking_number = $data['tracking_number'];
    $status = $data['status'];

    // Sipariş bul
    $orders = wc_get_orders([
        'meta_key'   => '_tracking_number',
        'meta_value' => $tracking_number,
        'limit'      => 1,
    ]);

    if (!empty($orders)) {
        $order = $orders[0];

        // Teslim edildiyse
        if ($status === 'DELIVERED') {
            $order->update_status('completed', 'Kargo teslim edildi.');
        }

        // Müşteriye bildirim
        WC()->mailer()->emails['WC_Email_Customer_Note']->trigger(
            $order->get_id(),
            'Kargo durumunuz: ' . $status
        );
    }

    return rest_ensure_response(['success' => true]);
}

Çoklu Kargo Fiyat Karşılaştırması

// En ucuz kargo seçeneklerini göster
function get_shipping_rates($weight, $city) {
    $rates = [];

    // MNG Kargo tarifesi
    $rates['mng'] = [
        'name'  => 'MNG Kargo (1-3 İş Günü)',
        'price' => calculate_mng_rate($weight, $city),
    ];

    // Yurtiçi Kargo tarifesi
    $rates['yurtici'] = [
        'name'  => 'Yurtiçi Kargo (1-3 İş Günü)',
        'price' => calculate_yurtici_rate($weight, $city),
    ];

    // Fiyata göre sırala
    usort($rates, fn($a, $b) => $a['price'] <=> $b['price']);

    return $rates;
}

Sonuç

Kargo entegrasyonu, e-ticaret operasyonlarını otomatize eder ve müşteri memnuniyetini artırır. Otomatik kargo oluşturma, webhook ile durum takibi ve çoklu kargo karşılaştırması ile profesyonel lojistik altyapısı kurabilirsiniz. Buyukweb e-ticaret hosting çözümleriyle bu entegrasyonlar sorunsuz çalışır.


Ilgili Buyukweb Hizmetleri:


E-Ticaret Altyapi Rehberi

Platform Secimi

WooCommerce: Esnek, genis eklenti. Kucuk-orta isletmeler.
PrestaShop: Guclü stok, coklu dil.
OpenCart: Hafif, kolay kurulum.
Shopify: Hosted, teknik bilgi gerektirmez.

Odeme

iyzico, PayTR, Param sanal pos. 3D Secure zorunlu. Kapida odeme onemli. Taksit seceenekleri donusumu arttirir.

Marketplace Entegrasyonu

Amazon, Trendyol, Hepsiburada, N11 icin entegrator yazilimi. Stok senkronizasyonu kritik. Coklu kanal strateji.

Performans

4 GB RAM, 2 vCPU, NVMe SSD minimum. CDN ile gorsel hizi. Yuksek trafik donemlerinde kaynak artirin.

Guvenlik

PCI DSS uyumu. Odeme bilgisi saklamayin. SSL, WAF, KVKK uyumlulugu zorunlu.

SEO

Product schema ekleyin. Gorsel optimize edin. Meta bilgilerini ozellestirin. Google Shopping entegrasyonu.

Sik Sorulan Sorular

Hosting mi VDS mi?

500 altinda ziyaretci hosting yeterli. 1000+ veya marketplace entegrasyonu icin VDS oneriyoruz.

Marketplace entegrasyonu icin ne gerekir?

Sabit IP VDS, entegrator yazilimi, API erisimleri. Buyukweb E-Ticaret VDS bu icin tasarlanmistir.

Sonuc

Basarili e-ticaret guclü altyapi, dogru platform ve etkili pazarlama birlesimdir. VDS ile isletmenizi olceklendirin.

E-Ticaret Baslangic Kontrol Listesi

Yasal

  • Sirket/sahis kurulumu
  • Vergi levhasi
  • Mesafeli satis sozlesmesi
  • KVKK aydinlatma metni
  • Cerez politikasi
  • Iade kosullari

Teknik

  • Hosting/VDS secimi
  • SSL sertifikasi
  • E-ticaret platformu
  • Sanal pos (3D Secure)
  • Kargo entegrasyonu
  • E-fatura entegrasyonu
  • Google Analytics + Search Console

Pazarlama

  • Google Business Profile
  • Sosyal medya hesaplari
  • Google Shopping
  • Facebook/Instagram Shop
  • E-posta pazarlama

E-Ticaret VDS vs Ev Interneti

Ozellik Ev Interneti E-Ticaret VDS
IP Dinamik Sabit
Temizlik Bilinmiyor Temiz
Kesinti Elektrik/internet %99.8 uptime
Hiz Degisken 1 Gbps
Guvenlik Dusuk DDoS korumali

Marketplace islemleri icin sabit ve temiz IP kritik. Ban riski en aza iner.

Hosting ve Sunucu Terimleri Sozlugu

Terim Aciklama
VDS Virtual Dedicated Server - Sanal ozel sunucu
NVMe SSD Non-Volatile Memory Express - En hizli disk teknolojisi
LiteSpeed Yuksek performansli web sunucu yazilimi
CloudLinux Paylasimli hosting icin kaynak izolasyon isletim sistemi
cPanel Populer web hosting kontrol paneli
Plesk Web hosting ve sunucu yonetim paneli
KVM Kernel-based Virtual Machine - Tam sanallastirma teknolojisi
DDoS Distributed Denial of Service - Dagitik hizmet engelleme saldirisi
SSL/TLS Veri iletisimini sifreleyen guvenlik protokolu
TTFB Time to First Byte - Sunucu yanit suresi
CDN Content Delivery Network - Icerik dagitim agi
WAF Web Application Firewall - Web uygulama guvenligi duvari
IOPS Input/Output Operations Per Second - Disk performans olcusu
Uptime Sunucunun kesintisiz calisma suresi yuzdesi
Bandwidth Veri transfer kapasitesi

Bu terimleri anlamak, hosting ve sunucu hizmetlerini daha bilinçli secmenize yardimci olur. Detayli bilgi icin Buyukweb blog yazilarini takip edin veya teknik destek ekibimize danisIn.

Teknik Destek ve Yardim Kanallari

Buyukweb olarak musterilerimize birden fazla destek kanali sunuyoruz:

Canli Destek (Tawk.to)

Web sitemiz uzerinden 7/24 canli destek ile aninda yardim alin. Teknik sorulariniz, fatura islemleriniz ve genel bilgi talepleriniz icin canli destek ekibimiz hizmetinizdedir.

Telefon Destegi

0850 302 60 70 numarasindan hafta ici ve hafta sonu teknik destek alabilirsiniz. Acil durumlar ve karmasik sorunlar icin telefon destegi en hizli cozum yoludur.

E-posta Destegi

destek@buyukweb.com adresine detayli sorun tanimlamanizi gonderin. Ekran goruntuleri ve hata mesajlari ile birlikte gonderdiginiz talepler daha hizli cozumlenir.

Musteri Paneli

my.buyukweb.com uzerinden destek talepleri olusturun, faturalarinizi yonetin ve hizmetlerinizi kontrol edin. Ticket sistemi ile tum iletisiminiz kayit altindadir.

Bilgi Bankasi

Blog yazilarimiz ve rehberlerimiz ile sik karsilasilan sorunlarin cozumlerini kendiniz bulabilirsiniz. WordPress kurulumu, DNS ayarlari, e-posta yapilandirmasi gibi konularda adim adim rehberler mevcuttur.

Buyukweb teknik ekibi, hosting alaninda 17 yillik tecrubesi ile her turlu sorununuza profesyonel cozum sunar.

Etiketler:

#kargo entegrasyonu#mng kargo#woocommerce kargo#lojistik#sipariş takibi#desi hesaplama

Bu yazıyı paylaş