This commit is contained in:
@@ -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
|
## Features
|
||||||
|
|
||||||
### 🚀 OpenCart 3 Compatibility
|
### 🚀 Automatic Product Status Management
|
||||||
- Fully compatible with OpenCart 3.x versions
|
- Automatically disables products when quantity reaches zero after an order
|
||||||
- Uses OCMOD (OpenCart Modification) system for safe modifications
|
- Re-enables products when stock is replenished (e.g., through order cancellation or manual adjustment)
|
||||||
- No core file changes required
|
- No core file changes required - uses OCMOD system
|
||||||
|
|
||||||
### 📦 Module Structure
|
### 📦 Module Structure
|
||||||
- **install.xml**: OCMOD installation file with modification definitions
|
- **install.xml**: OCMOD installation file with modification definitions
|
||||||
@@ -30,24 +30,29 @@ A comprehensive template for developing custom modules and extensions for OpenCa
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Clone this repository
|
1. Clone this repository
|
||||||
2. Customize the `install.xml` with your module details:
|
2. The `install.xml` is pre-configured for the Product Phase Out functionality
|
||||||
- Set `<name>`, `<code>`, and `<version>`
|
3. Place any additional module files in the `upload/` directory if needed
|
||||||
- Add your modifications in the `<file>` sections
|
|
||||||
3. Place your module files in the `upload/` directory
|
|
||||||
4. Add installation scripts if needed (`install.php`, `install.sql`)
|
4. Add installation scripts if needed (`install.php`, `install.sql`)
|
||||||
5. Push to your repository to trigger automatic release build
|
5. Push to your repository to trigger automatic release build
|
||||||
|
|
||||||
## Usage
|
## 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
|
### For Store Owners
|
||||||
1. Download the generated `.ocmod.zip` from releases
|
1. Download the generated `.ocmod.zip` from releases
|
||||||
2. Upload via OpenCart's Extension Installer
|
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
|
3. Install and configure the module through admin panel
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|||||||
+13
-2
@@ -1,11 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<modification>
|
<modification>
|
||||||
<name></name>
|
<name><![CDATA[Product Phase out]]></name>
|
||||||
<code></code>
|
<code><![CDATA[disable product when out of stock]]></code>
|
||||||
<author><![CDATA[<b style="color: green">MY-Dev | </b><b>Mohamed Youssef</b>]]></author>
|
<author><![CDATA[<b style="color: green">MY-Dev | </b><b>Mohamed Youssef</b>]]></author>
|
||||||
<link>https://my-dev.pro</link>
|
<link>https://my-dev.pro</link>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
|
|
||||||
|
<file path="catalog/model/checkout/order.php">
|
||||||
|
<operation error="skip">
|
||||||
|
<search><![CDATA[$this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");]]></search>
|
||||||
|
<add position="replace"><![CDATA[$this->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'");]]></add>
|
||||||
|
</operation>
|
||||||
|
<operation error="skip">
|
||||||
|
<search><![CDATA[$this->db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'");]]></search>
|
||||||
|
<add position="replace"><![CDATA[$this->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'");]]></add>
|
||||||
|
</operation>
|
||||||
|
</file>
|
||||||
|
|
||||||
<file path="">
|
<file path="">
|
||||||
<operation error="skip">
|
<operation error="skip">
|
||||||
<search><![CDATA[]]></search>
|
<search><![CDATA[]]></search>
|
||||||
|
|||||||
Reference in New Issue
Block a user