diff --git a/admin/products.php b/admin/products.php
index 5a348a9..1383d11 100644
--- a/admin/products.php
+++ b/admin/products.php
@@ -50,16 +50,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) {
if (!has_permission('products_edit')) {
$message = '
Access Denied: You do not have permission to edit products.
';
} else {
- $stmt = $pdo->prepare("UPDATE products SET name = ?, name_ar = ?, category_id = ?, price = ?, vat_percent = ?, cost_price = ?, stock_quantity = ?, description = ?, image_url = ?, promo_discount_percent = ?, promo_date_from = ?, promo_date_to = ?, is_loyalty = ?, show_in_qorder = ? WHERE id = ?");
- $stmt->execute([$name, $name_ar, $category_id, $price, $vat_percent, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty, $show_in_qorder, $id]);
+ $stmt = $pdo->prepare("UPDATE products SET name = ?, name_ar = ?, category_id = ?, price = ?, vat_percent = ?, cost_price = ?, stock_quantity = ?, description = ?, image_url = ?, promo_discount_percent = ?, promo_date_from = ?, promo_date_to = ?, is_loyalty = ?, show_in_qorder = ?, show_in_online_order = ? WHERE id = ?");
+ $stmt->execute([$name, $name_ar, $category_id, $price, $vat_percent, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty, $show_in_qorder, $show_in_online_order, $id]);
$message = 'Product updated successfully!
';
}
} elseif ($action === 'add_product') {
if (!has_permission('products_add')) {
$message = 'Access Denied: You do not have permission to add products.
';
} else {
- $stmt = $pdo->prepare("INSERT INTO products (name, name_ar, category_id, price, vat_percent, cost_price, stock_quantity, description, image_url, promo_discount_percent, promo_date_from, promo_date_to, is_loyalty, show_in_qorder) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
- $stmt->execute([$name, $name_ar, $category_id, $price, $vat_percent, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty, $show_in_qorder]);
+ $stmt = $pdo->prepare("INSERT INTO products (name, name_ar, category_id, price, vat_percent, cost_price, stock_quantity, description, image_url, promo_discount_percent, promo_date_from, promo_date_to, is_loyalty, show_in_qorder, show_in_online_order) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ $stmt->execute([$name, $name_ar, $category_id, $price, $vat_percent, $cost_price, $stock_quantity, $description, $image_url, $promo_discount_percent, $promo_date_from, $promo_date_to, $is_loyalty, $show_in_qorder, $show_in_online_order]);
$message = 'Product created successfully!
';
}
}
@@ -217,6 +217,11 @@ include 'includes/header.php';
QR Menu
+
+
+ Online
+
+
= htmlspecialchars($product['name_ar'] ?? '') ?>
@@ -381,6 +386,13 @@ include 'includes/header.php';
Make this product visible in the customer QR menu
+
+
+
+
+
Make this product visible in the Online Ordering page
+
+
@@ -419,6 +431,7 @@ function prepareAddForm() {
document.getElementById('productId').value = '';
document.getElementById('productImagePreview').style.display = 'none';
document.getElementById('productShowInQorder').checked = true;
+ document.getElementById('productShowInOnlineOrder').checked = true;
}
function prepareEditForm(p) {
@@ -439,6 +452,7 @@ function prepareEditForm(p) {
document.getElementById('productPromoTo').value = p.promo_date_to || '';
document.getElementById('productIsLoyalty').checked = p.is_loyalty == 1;
document.getElementById('productShowInQorder').checked = p.show_in_qorder == 1;
+ document.getElementById('productShowInOnlineOrder').checked = (p.show_in_online_order === undefined ? true : p.show_in_online_order == 1);
if (p.image_url) {
const preview = document.getElementById('productImagePreview');
diff --git a/db/migrations/049_add_show_in_online_order.sql b/db/migrations/049_add_show_in_online_order.sql
new file mode 100644
index 0000000..b6e37a4
--- /dev/null
+++ b/db/migrations/049_add_show_in_online_order.sql
@@ -0,0 +1 @@
+ALTER TABLE `products` ADD COLUMN IF NOT EXISTS `show_in_online_order` TINYINT(1) DEFAULT 1;
\ No newline at end of file
diff --git a/online_order.php b/online_order.php
index 97daad1..fcd8422 100644
--- a/online_order.php
+++ b/online_order.php
@@ -114,7 +114,7 @@ if ($table_id > 0) {
$outlet_id = (int)($table_info['outlet_id'] ?? 0);
$categories = $pdo->query("SELECT * FROM categories WHERE is_deleted = 0 ORDER BY sort_order")->fetchAll();
-$all_products = $pdo->query("SELECT p.*, c.name as category_name, c.name_ar as category_name_ar FROM products p JOIN categories c ON p.category_id = c.id WHERE p.is_deleted = 0 AND p.show_in_qorder = 1 AND c.is_deleted = 0")->fetchAll();
+$all_products = $pdo->query("SELECT p.*, c.name as category_name, c.name_ar as category_name_ar FROM products p JOIN categories c ON p.category_id = c.id WHERE p.is_deleted = 0 AND p.show_in_online_order = 1 AND c.is_deleted = 0")->fetchAll();
// Fetch variants
$variants_raw = $pdo->query("SELECT * FROM product_variants WHERE is_deleted = 0 ORDER BY price_adjustment ASC")->fetchAll();