Hello friends,
I made this addon to integrate with a specifc chat app called Karzoun , the folder structure be like:
app
└── addons
└── karzoun
├── addon.xml
├── controllers
│ ├── backend
│ │ └── karzoun_dash.php
│ └── frontend
├── func.php
├── init.php
└── templates
└── addons
└── karzoun
└── karzoun_dash.tpl
and the doc of the karzoun chat is:
however whenever am installing the addon on cs cart , the website completely crashes so I do ssh to my server , remove the addon directory completely , then my cs cart website works again
karzoun_dash.php
init.php
<?php if (!defined('BOOTSTRAP')) { die('Access denied'); } fn_register_hooks( 'dispatch_before_display' ); ?>func.php
<?php if (!defined('BOOTSTRAP')) { die('Access denied'); } function fn_karzoun_dispatch_before_display(&$controller, &$mode, &$action, &$dispatch_extra, &$area) { if ($controller == 'karzoun' && $mode == 'view') { $controller = 'karzoun_dash'; $mode = 'view'; } } ?>karzoun_dash.tpl
Customer Orders body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 0; display: flex; justify-content: center; align-items: center; height: 100vh; flex-direction: column; } h1 { color: #333; } .container { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } input[type="text"] { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ccc; border-radius: 4px; font-size: 16px; } button { padding: 10px 20px; background-color: #007bff; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; } button:hover { background-color: #0056b3; } .orders { margin-top: 20px; } .order { background: #f9f9f9; padding: 10px; border: 1px solid #ddd; border-radius: 4px; margin-bottom: 10px; } function searchOrders() { const query = document.getElementById('searchQuery').value; fetch(`/index.php?dispatch=karzoun.search&query=${encodeURIComponent(query)}`) .then(response => response.json()) .then(data => { const ordersDiv = document.getElementById('orders'); ordersDiv.innerHTML = ''; if (data.orders.length > 0) { data.orders.forEach(order => { const orderElement = document.createElement('div'); orderElement.className = 'order'; orderElement.innerHTML = `Order ID: ${order.order_id}, Total: ${order.total}`; ordersDiv.appendChild(orderElement); }); } else { ordersDiv.innerHTML = 'No orders found'; } }) .catch(error => console.error('Error fetching customer data:', error)); } window.addEventListener("message", function(event) {
if (event.origin !== "https://app.karzoun.chat") {
return;
}
var context = event.data;
document.getElementById('searchQuery').value = context.customerName || context.customerPhone || context.customerEmail;
searchOrders();
}, false);
</script>
Customer Orders
SearchPlease help reviewing the code, i tried every way possibe
there is a solution where i can build an entirly web application connecting the two platofroms through api, but I consisit of addon for cs cart