1. Go to this page and download the library: Download codesbytvt/smartmart360-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codesbytvt / smartmart360-sdk example snippets
// This should work without tMartClient;
use SmartMart\External\TRANSACTION_TYPES;
use SmartMart\External\PARTY_TYPES;
// Create client
$client = new SmartMartClient($url, $apiKey, $clientId, $appName);
est class loading
try {
$reflection = new ReflectionClass('SmartMart\External\SmartMartClient');
echo "✅ SmartMartClient class found\n";
} catch (Exception $e) {
echo "❌ SmartMartClient class not found: " . $e->getMessage() . "\n";
}
// Test constants
if (class_exists('SmartMart\External\TRANSACTION_TYPES')) {
echo "✅ TRANSACTION_TYPES class found\n";
} else {
echo "❌ TRANSACTION_TYPES class not found\n";
}
// Add this to your script if autoloading fails
set_include_path(get_include_path() . PATH_SEPARATOR . 'vendor/');
use SmartMart\External\SmartMartClient;
use SmartMart\External\DOCUMENT_TYPES; // Primary - Document Types
use SmartMart\External\PARTY_TYPES; // Party Types
use SmartMart\External\TRANSACTION_TYPES; // Legacy Transaction Types
$client = new SmartMartClient(
'https://api.smartmart360.com', // Base URL
'your_api_key_here', // API Key
1, // Your client/branch ID
'HOSPITAL' // Application name
);
if ($client->healthCheck()) {
echo "Connected\n";
}
// Complete catalogue (default)
$allItems = $client->getItems(['search' => 'paracetamol']);
// Only items in stock
$availableItems = $client->getItems(['search' => 'paracetamol'], 'in_stock');
// Items needing restock (below reorder level)
$lowStockItems = $client->getItems([], 'low_stock', 5);
// Out of stock items (procurement list)
$outOfStockItems = $client->getItems([], 'out_of_stock');
// With variant details (e(['search' => 'paracetamol']);
// These still work but use the new unified API internally
$catalog = $client->getItemCatalog(['search' => 'medicine']);
$stockReport = $client->getStockReport(['search' => 'paracetamol']);
$lowStock = $client->getLegacyLowStockItems();
// Get all categories
$categories = $client->getCategories();
// Get subcategories of a parent category
$subCategories = $client->getCategories(['parent_id' => 5]);
// Search categories
$categories = $client->getCategories(['search' => 'medicine']);
// Paginated results
$categories = $client->getCategories(['page' => 1, 'pageLength' => 50]);
// Browse items with stock filtering
$client->getItems(['search' => 'paracetamol', 'page' => 1]);
$client->searchItems('paracetamol 500mg');
$client->getItem(123);
$client->checkStock(123, $locationId);
// Get items for specific document type (RECOMMENDED)
$items = $client->getItemsForTransaction(DOCUMENT_TYPES::SALES_INVOICE, $locationId);
// Get items for legacy transaction type (Only if needed)
$items = $client->getItemsForTransaction(25, $locationId, true);
$client->createTransaction(...); // create order
$client->getTransaction($transactionId); // fetch by id
$client->getTransactionByReference('RX-12345'); // fetch by your ref
$client->getTransactionStatus($transactionId); // status
$client->listTransactions(['from_date' => '2025-01-01', 'to_date' => '2025-01-31']);
$client->cancelTransaction($transactionId, 'reason here');
$client->updateTransactionStatus($transactionId, 5, 'In transit'); // example status id
// Get transaction summary for a date range
$client->getTransactionSummary('2025-01-01', '2025-01-31');
// Filter summary by document type (RECOMMENDED)
$client->getTransactionSummary('2025-01-01', '2025-01-31', ['document_type_id' => DOCUMENT_TYPES::SALES_INVOICE]);
// Filter summary by legacy transaction type
$client->getTransactionSummary('2025-01-01', '2025-01-31', ['transaction_type_id' => 25]);
$client->getStockReport(['location_id' => 1]);
$client->getLowStockItems();