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
|
||||
|
||||
### 🚀 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 `<name>`, `<code>`, and `<version>`
|
||||
- Add your modifications in the `<file>` 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
|
||||
|
||||
+13
-2
@@ -1,11 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<modification>
|
||||
<name></name>
|
||||
<code></code>
|
||||
<name><![CDATA[Product Phase out]]></name>
|
||||
<code><![CDATA[disable product when out of stock]]></code>
|
||||
<author><![CDATA[<b style="color: green">MY-Dev | </b><b>Mohamed Youssef</b>]]></author>
|
||||
<link>https://my-dev.pro</link>
|
||||
<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="">
|
||||
<operation error="skip">
|
||||
<search><![CDATA[]]></search>
|
||||
|
||||
Reference in New Issue
Block a user