A powerful PrestaShop module that allows you to restrict specific payment methods based on cart content (products, categories, or brands). Perfect for handling special payment restrictions for specific product types, categories, or manufacturers.
- π Server-Side Payment Filtering - Secure restriction that cannot be bypassed by users
- π― Multiple Restriction Criteria - Filter by product ID, category ID, or brand/manufacturer ID
- π¬ Custom User Messages - Display personalized messages explaining why certain payment methods are unavailable
- πͺ Multi-Shop Support - Different rules for different shops in multi-shop environments
- β‘ Performance Optimized - Advanced caching system and optimized database queries (solves N+1 problem)
- π Bulk Actions - Enable, disable, or delete multiple rules at once
- π AJAX Search - User-friendly admin interface with instant search for products, categories, and brands
- π Activity Logging - Track when and why payment restrictions are applied
- π Multi-Language Support - Full translation support with PrestaShop 8 XLIFF system
- π¨ Theme Compatible - Works with most PrestaShop themes (includes multiple fallbacks)
Unlike basic JavaScript-only solutions, this module implements a double-layer protection system:
- Primary Layer: Server-side filtering via
paymentOptionshook (cannot be bypassed) - Secondary Layer: Client-side fallback for older themes + user-friendly messages
- 1-hour caching system to minimize database queries
- Bulk SQL queries eliminate the N+1 problem
- Lazy loading of assets (only on checkout pages)
- Database indexes on all search fields
- Tested with PrestaShop 1.7.6+ and 8.x
- Multi-shop and multi-language support
- Automatic cache invalidation on rule changes
- Complete logging system for debugging
- Server-side validation to prevent invalid configurations
- Download the latest release from GitHub Releases
- Upload the
restrictpaymentsfolder to/modulesdirectory of your PrestaShop installation - Go to Modules > Module Manager in your PrestaShop back office
- Find "Restrict Payment Methods" and click Install
- Download the module ZIP file
- Go to Modules > Module Manager
- Click Upload a Module and select the ZIP file
- Click Configure after installation
- Navigate to Payment > Restrict Payments in your PrestaShop back office
- Click Add New Rule
- Configure the rule:
- Rule Name: Give your rule a descriptive name (supports multiple languages)
- Custom Message (optional): Message displayed to customers when payment methods are restricted
- Product ID: Restrict payments when a specific product is in cart
- Category ID: Restrict payments when products from a specific category are in cart
- Brand ID: Restrict payments when products from a specific manufacturer/brand are in cart
- Select which payment methods to restrict when the criteria match
- Multiple payment methods can be selected
- Enabled: Activate or deactivate the rule
- Click Save
Note: You must specify at least one criterion (product, category, or brand) and at least one payment method to restrict.
Instead of manually entering IDs, use the built-in search buttons:
- Select Product: Search products by name or reference
- Select Category: Search categories by name
- Select Brand: Search manufacturers/brands by name
Rule: "No COD for Electronics"
Category ID: 3 (Electronics)
Restricted Methods: Cash on Delivery
Custom Message: "Cash on delivery is not available for electronic products."
Rule: "No PayPal for Brand X"
Brand ID: 5
Restricted Methods: PayPal
Custom Message: "PayPal payments are not available for this brand."
Rule: "Premium Product Restrictions"
Product ID: 123
Restricted Methods: Cash on Delivery, Check Payment
Custom Message: "Only credit card and bank transfer are available for this product."
The module fully supports PrestaShop's multi-shop feature:
- Create different restriction rules for different shops
- Rules can be shop-specific or shared across shops
- Each shop maintains its own rule cache for optimal performance
- Rule names are translatable for each language
- Custom messages can be different for each language
- Admin interface automatically adapts to the current language
- Compatible with PrestaShop 8's modern XLIFF translation system
If you're upgrading from version 1.x to 2.0:
- The module will automatically upgrade your database schema
- All existing rules will be preserved
- New features (custom messages, multi-shop support, server-side filtering) will be available immediately
- Clear your browser cache after upgrading
paymentOptions- Server-side payment filtering (main security layer)displayPaymentTop- Client-side fallback + user messagesactionFrontControllerSetMedia- Load frontend assets (checkout only)displayBackOfficeHeader- Load admin assets
ps_restrict_payments_rule- Main rules tableps_restrict_payments_rule_lang- Multi-language supportps_restrict_payments_rule_shop- Multi-shop associations
The module automatically clears its cache when:
- A rule is created, updated, or deleted
- The module is uninstalled
- Manual: Call
$module->clearCache()from code
- Caching: Rules cached with 1-hour TTL
- Bulk Queries: Product categories fetched in single JOIN query
- Lazy Loading: Assets loaded only on checkout pages
- Indexed Database: All search fields properly indexed
restrictpayments/
βββ restrictpayments.php # Main module class
βββ classes/
β βββ RestrictPaymentsRule.php # Model with multishop/multilang
βββ controllers/admin/
β βββ AdminRestrictPaymentsController.php # Admin interface
βββ sql/
β βββ install.php # Database installation
β βββ uninstall.php # Database cleanup
βββ upgrade/
β βββ upgrade-2.0.0.php # Upgrade scripts
βββ views/
β βββ js/ # JavaScript files
β βββ css/ # Stylesheets
β βββ templates/ # Smarty templates
βββ translations/ # XLIFF translation files
- Verify the rule is enabled (green toggle in the list)
- Check that product/category/brand IDs are correct
- Clear PrestaShop cache: Advanced Parameters > Performance > Clear Cache
- Check logs: Advanced Parameters > Logs
- Ensure you entered a custom message for the current language
- Verify your theme uses the
displayPaymentTophook - Check browser console for JavaScript errors
- Ensure multi-shop is enabled in PrestaShop settings
- Verify the rule is associated with the correct shop
- Clear cache for the specific shop context
- Check if caching is working (enable debug mode to see cache hits)
- Verify database indexes exist (re-run module installation if needed)
- Consider reducing the number of active rules if you have many
- PrestaShop: 1.7.6.0 or higher (including 8.x)
- PHP: 7.1+ (7.2+ recommended for PrestaShop 8)
- MySQL: 5.6+ or MariaDB 10.0+
- PHP Extensions: mbstring, gd, curl, xml, zip
This module is released under the MIT License. See LICENSE file for details.
You are free to:
- β Use commercially
- β Modify
- β Distribute
- β Private use
This module is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement.
Important:
- β Always test in a development/staging environment before production
- β Create a complete backup of your store before installation
- β Verify compatibility with your PrestaShop version and other modules
- β The author is not responsible for any damage, data loss, or issues caused by using this module
Use at your own risk. For production environments, consider using professional installation services.
Found a bug or have a feature request? Please open an issue on GitHub Issues.
When reporting bugs, please include:
- PrestaShop version
- PHP version
- Module version
- Steps to reproduce
- Error messages (if any)
See CHANGELOG.md for a detailed version history.
This module is completely free and always will be.
If you're using it in your business and it's saving you development time, please consider supporting its development:
Even a small contribution helps me:
- β Keep the module updated with new PrestaShop versions
- β Fix bugs faster
- β Add new features based on community feedback
- β Provide better documentation and support
Thank you for your support! π
Need help with your PrestaShop store? I offer professional services:
- π¨ Module Customization - Tailored modifications to fit your specific needs
- π Complete PrestaShop E-commerce Development - From setup to launch
- β‘ Performance Optimization - Speed up your store and improve conversions
- π§ Custom Module Development - Build exactly what your business needs
- π Support & Maintenance - Keep your store running smoothly
Contact Me:
- π§ Email: info@ettorestani.it
- π Website: www.ettorestani.it
Made with β€οΈ by Ettore Stani
If this module helped you, please consider leaving a β on GitHub!