From e716e9aee28a684abac1157fbc3bd3dbf0c1acbd Mon Sep 17 00:00:00 2001 From: Mohamed Youssef Date: Fri, 10 Apr 2026 20:10:00 +0200 Subject: [PATCH] first commit --- README.md | 37 +++++++++++++++++++++---------------- install.xml | 15 +++++++++++++-- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 4234d9a..cbd55d7 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -# OpenCart 3 Module Template +# Product Phase Out Module for OpenCart 3 -A comprehensive template for developing custom modules and extensions for OpenCart 3.x e-commerce platform. +An OpenCart 3.x module that automatically disables products when they go out of stock and re-enables them when stock is replenished. ## Features -### 🚀 OpenCart 3 Compatibility -- Fully compatible with OpenCart 3.x versions -- Uses OCMOD (OpenCart Modification) system for safe modifications -- No core file changes required +### 🚀 Automatic Product Status Management +- Automatically disables products when quantity reaches zero after an order +- Re-enables products when stock is replenished (e.g., through order cancellation or manual adjustment) +- No core file changes required - uses OCMOD system ### 📦 Module Structure - **install.xml**: OCMOD installation file with modification definitions @@ -30,24 +30,29 @@ A comprehensive template for developing custom modules and extensions for OpenCa ## Installation 1. Clone this repository -2. Customize the `install.xml` with your module details: - - Set ``, ``, and `` - - Add your modifications in the `` sections -3. Place your module files in the `upload/` directory +2. The `install.xml` is pre-configured for the Product Phase Out functionality +3. Place any additional module files in the `upload/` directory if needed 4. Add installation scripts if needed (`install.php`, `install.sql`) 5. Push to your repository to trigger automatic release build ## Usage -### For Module Developers -1. Use this template as a starting point for new OpenCart modules -2. Define your modifications in `install.xml` -3. Add custom files to `upload/` directory -4. Test locally before deploying - ### For Store Owners 1. Download the generated `.ocmod.zip` from releases 2. Upload via OpenCart's Extension Installer +3. The module will automatically manage product status based on stock levels + +### For Developers +1. Modify `install.xml` to customize the behavior +2. Add custom files to `upload/` directory +3. Test locally before deploying + +## Changelog + +### v1.0.0 +- Initial release +- Automatic product disabling when out of stock +- Automatic product re-enabling when stock is replenished 3. Install and configure the module through admin panel ## Requirements diff --git a/install.xml b/install.xml index 5a69cd6..6dc4b47 100644 --- a/install.xml +++ b/install.xml @@ -1,11 +1,22 @@ - - + + MY-Dev | Mohamed Youssef]]> https://my-dev.pro 1.0.0 + + + db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");]]> + db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$order_product['quantity'] . "), status = IF((quantity - " . (int)$order_product['quantity'] . ") = 0, 0, 1) WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");]]> + + + db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");]]> + db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int)$order_product['quantity'] . "), status = IF((quantity + " . (int)$order_product['quantity'] . ") > 0, 1, status) WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");]]> + + +