`n
🛡️ Security-First Module

Category Discount | PrestaShop Module

A secure PrestaShop module for managing category-based discounts with time period settings, comprehensive rule management, and protection against security vulnerabilities.

1 - 100%
Discount Range
CSRF
Protection
1.7.x - 9.0.x
PrestaShop

Project Overview

Category Discount is a PrestaShop module that allows you to manage discounts on specific product categories. It offers features for applying, enabling, and disabling discounts with time period settings for each rule. The module provides secure discount management and protects against common security vulnerabilities.

Key Features

  • Apply discounts to selected product categories
  • Set discount percentage up to 100%
  • Define time periods with start and end dates for each rule
  • Protection against activating discounts when other special prices exist
  • Prevents disabling and uninstalling the module if there are active discounts
  • Notifications to administrators for discounts nearing expiration
  • CSRF (Cross-Site Request Forgery) protection using Tools::getAdminTokenLite
  • SQL Injection protection with secure database methods
  • Server date and time display for accurate discount timing
  • Comprehensive rule management interface

Technical Implementation

The module was built specifically for PrestaShop 1.7.x with PHP 7.1+ compatibility. It implements secure coding practices including CSRF protection using Tools::getAdminTokenLite and SQL injection prevention through Db::getInstance()->execute and Db::getInstance()->executeS methods. The module integrates seamlessly with PrestaShop's promotion system while maintaining security standards.

Security & Protection

Security is a primary focus of this module. All administrative actions are protected using Tools::getAdminTokenLite to prevent CSRF attacks. Database operations utilize secure methods to protect against SQL injection. The module also prevents conflicts by checking for existing special prices before applying category discounts, ensuring data integrity and preventing pricing conflicts.

Installation Instructions

1

Download Module

Download the module's .zip file from the PrestaShop Marketplace or module repository.

2

Access Admin Panel

Go to your PrestaShop admin panel and navigate to Modules and Services → Modules.

3

Upload Module

Click on "Upload a module" and upload the .zip file you downloaded.

4

Install Module

Once the upload is complete, click the "Install" option to activate the module.

5

Access Module

After installation, the module will appear in the Promotions section of your admin panel.

Usage Instructions

Creating a New Discount Rule

  1. Navigate to the Promotions section → Category Discount
  2. Select the category where you want to apply the discount
  3. Set the discount percentage (up to 100%)
  4. Choose whether the rule should be active or inactive
  5. Set the start and end dates for the discount period
  6. Click "Save" to activate the rule

Important Note

If a special price already exists for any product in the category, the module will prevent the discount from being applied and display a relevant notification to maintain pricing integrity.

Troubleshooting

The discount is not applying

Ensure there are no other active special prices for the products in the category, as the module does not override other prices to maintain data integrity.

I can't uninstall the module

Make sure there are no active discount rules. Disable or delete all rules from the module's management page before attempting to uninstall.

Server Date and Time

Discounts start and end based on the server's date and time. The module displays the current date and time at the bottom of the configuration form to help you adjust the discount accordingly.

Frequently Asked Questions

Can I create a discount for more than one category at the same time?

No, the module allows setting up a discount for only one category at a time. To create multiple discounts, you need to define rules for each category separately.

What happens if the module is disabled with active discounts?

The module is designed to prevent being disabled or uninstalled if there are active rules. You will need to disable all rules first.

How will I be notified about expiring discounts?

The module will display notifications in the admin panel when a discount's expiration date is approaching.

Need a Custom E-commerce Solution?

Let's discuss how I can help bring your online store vision to life with the same level of expertise and attention to detail demonstrated in the Rima project.