Merhaba
Stockmount api ile opencarta düşen siparişleri stockmounta aktarmak istiyoruz. Stockmount api dokümanı var fakat uğraştım olmadı bir türlü. Bu konuda makul ücretle yardımcı olabilecek arkadaş varsa yazabilir.
Stockmount api ile ürün güncelleme
6
●132
- 14-12-2024, 23:52:44
- 15-12-2024, 00:54:45Aşağıdaki php kod'unu kendinize göre geliştirebilirsiniz düzenleyebilrisiniz.
- cronjob ile otomatik senkronize edebilirsiniz.
(Farklı programlama dilleri ile daha gelişmiş bir otomasyon çözümü isterseniz API entegrasyonu için iletişime geçebilrisiniz.)
<?php // Güvenlik Kontrolü (örneğin IP kontrolü) $allowed_ips = ['123.456.789.0']; // Buraya güvenli IP adreslerini ekleyin if (!in_array($_SERVER['REMOTE_ADDR'], $allowed_ips)) { die("Erişim Engellendi."); } // OpenCart Veritabanı Bağlantısı $host = 'localhost'; $user = 'your_username'; // OpenCart veritabanı kullanıcı adı $password = 'your_password'; // OpenCart veritabanı parolası $dbname = 'your_opencart_database'; // OpenCart veritabanı adı $conn = new mysqli($host, $user, $password, $dbname); if ($conn->connect_error) { die("Bağlantı başarısız: " . $conn->connect_error); } $stockmount_api_url = 'api sipariş bağlantı linkinizi ekleyin.'; $api_key = 'your_api_key'; $sql = "SELECT * FROM oc_order WHERE order_status_id = 1"; // Durumu '1' olan siparişler (ödemeli) $result = $conn->query($sql); if ($result->num_rows > 0) { while ($order = $result->fetch_assoc()) { $order_data = [ 'order_id' => $order['order_id'], 'customer_name' => $order['firstname'] . ' ' . $order['lastname'], 'email' => $order['email'], 'phone' => $order['telephone'], 'shipping_address' => $order['shipping_address_1'], 'shipping_city' => $order['shipping_city'], 'shipping_postcode' => $order['shipping_postcode'], 'total' => $order['total'], // API'ye göndereceğiniz diğer sipariş bilgileri ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $stockmount_api_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($order_data)); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $api_key, 'Content-Type: application/json', ]); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($http_code == 200) { echo "Sipariş ID " . $order['order_id'] . " başarıyla gönderildi.<br>"; } else { echo "Sipariş ID " . $order['order_id'] . " gönderilemedi. Hata: " . $http_code . "<br>"; } } } else { echo "Hiç sipariş bulunamadı."; } $conn->close(); ?> - 15-12-2024, 01:49:35Biz ilk önce normal stockmountun sözde verdiği githubda verdiği örnek kodu bile çalıştırıp sipariş ekleyemedik stockmounta. Opencartı şimdi hiç karıştıramıyoruzki sizin kod bence çalışmaz için stockmount api secret yok kodda gördüğüm kadarıyla. Normal apiye sipariş girdirebilsek onu dünya gözüyle görsek zaten gerisini yaptıracağız. Stockmount hafta sonu çalışmıyor herhalde hiç bir soruya cuma akşamından beri dönüş alamadık. Siz makul bir ücrete stok mount api ile sipariş ekleme yaparım deerseniz tabi olur.
taylanweb adlı üyeden alıntı: mesajı görüntüle - 15-12-2024, 01:53:51https://e-outsample.stockmount.com/Hometaylanweb adlı üyeden alıntı: mesajı görüntüle
- 15-12-2024, 02:21:36Özelden entegrasyon için fiyat teklifini iletiyorum.
- SmIntegration-php 'deki SmIntegrationClass yapısına uygun çalışma hazırlanabilir.
- 15-12-2024, 02:25:42Bir türlü yapamadık. Siparişler olmasa bile en azından https://e-outsample.stockmount.com/H...roductQuantity un çalışabileceği bir kodda yardımı olabilecek kimse yok mu?
Böyle birşey yapmaya çalıştım githubdaki php sınıfına bakıp ama olmadı.
public function UpdateProductQuantity($Data, $SendMethod = 3)
{
$Services="/api/Product/UpdateProductQuantity";
$Options="POST";
try {
$this->ReuiredCheck(array("ProductId", "Quantity"), $Data);
switch ($SendMethod)
{
case 1:
$SetOrder=$this->HttpBuild($Data, $Services, $Options);
break;
case 2:
$SetOrder=$this->CurlQuery($Data, $Services, $Options);
break;
case 3:
default:
try
{
$SetOrder=$this->HttpBuild($Data, $Services, $Options);
break;
}catch(Exception $ex){
$SetOrder=$this->CurlQuery($Data, $Services, $Options);
break;
}
}
return $SetOrder;
} catch (Exception $ex) {
echo "Error: " , $ex->getMessage();
}
}