πŸ“Š State of Magento 2025 β†’

The Home for Magento 2 Excellence

Quality-tested Magento 2 modules. Explore. Evaluate. Elevate. #magento2

618 Modules
407 Ready
210 Need Help
πŸ† Leaderboard
Actively Maintained v1.0.0

Rollpix Disable Sales

rollpix/module-disable-sales

Temporarily disables sales functionality in the store, displaying a custom message. It hides "Add to Cart" buttons and blocks checkout to prevent purchases.

0
Downloads
0
GitHub Stars
Today
Last Release
0
Open Issues
Build Passing
Ready to install

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
32 warnings
– PHPStan

Tested on Magento 2.4.8-p3

Recent Test History

Each release is tested against the latest Magento version at that time.

v1.0.0 on Magento 2.4.8-p3
Feb 26, 2026

Share This Module's Status

Rollpix Disable Sales Magento compatibility status badge

README

Loaded from GitHub

Rollpix_DisableSales

Version en espaΓ±ol

SPONSOR: www.rollpix.com

Magento 2 module to temporarily disable sales in an online store without affecting catalog navigation. Ideal for high-demand situations, maintenance, or when you need to pause purchases without taking the site down.

Compatibility

| Requirement | Supported versions | |---|---| | PHP | 7.4 ~ 8.3 | | Magento | 2.4.x (Open Source / Commerce) |

Installation

Via composer (recommended)

composer require rollpix/module-disable-sales
bin/magento module:enable Rollpix_DisableSales
bin/magento setup:upgrade
bin/magento cache:flush

Manual

  1. Create the folder app/code/Rollpix/DisableSales in your Magento installation.
  2. Copy all files from this repository into that folder.
  3. Run:
bin/magento module:enable Rollpix_DisableSales
bin/magento setup:upgrade
bin/magento cache:flush

Admin Configuration

Go to Stores > Configuration > Rollpix > Disable Sales.

Admin Configuration

Configuration is divided into three sections:

General Settings

| Field | Type | Default | Description | |---|---|---|---| | Enable | Yes/No | No | Activate or deactivate sales blocking | | Message | Textarea | (see below) | Message shown to customers. Supports HTML in the banner and modal. Checkout/cart error messages display as plain text | | Also Disable Checkout | Yes/No | Yes | Block checkout access as an additional safety net |

Default message:

Debido a la alta demanda, las compras estan temporalmente suspendidas. Podes seguir navegando el catalogo. Volve pronto!

The message field supports HTML. You can use <strong>, <br>, <a href="...">, etc. HTML renders in the top banner and modal. Error messages shown in checkout and cart (via Magento message manager) automatically display as plain text.

Top Banner

| Field | Type | Default | Description | |---|---|---|---| | Show Top Banner | Yes/No | Yes | Display a dismissible banner at the top of the page | | Background Color | Color | #ff6b35 | Banner background color (hex format) | | Text Color | Color | #ffffff | Banner text color (hex format) | | Banner Message Custom CSS | Textarea | font-size: 14px; line-height: 1.4; | Inline CSS applied to the message text. Pre-loaded with defaults for easy editing |

The banner has a close button (X). Once closed, it won't show again in that browser session (uses localStorage). Reset by clearing localStorage or opening an incognito window.

Modal Popup

| Field | Type | Default | Description | |---|---|---|---| | Show Modal | Yes/No | No | Display a modal popup once per session | | Background Color | Color | #ffffff | Modal background color | | Text Color | Color | #333333 | Modal text color | | Modal Message Custom CSS | Textarea | font-size: 18px; line-height: 1.6; text-align: center; padding: 10px 20px; | Inline CSS applied to the modal message text. Pre-loaded with defaults |

The modal is displayed centered on screen, with a max-width of 600px. It appears once per browser session (uses sessionStorage). Includes an "Entendido" (Got it) button to close.

Banner and Modal can be active at the same time. They are independent of each other.


What the module does when active

1. Hides "Add to Cart" buttons

Conditional inline CSS hides .action.tocart and #product-addtocart-button buttons on:

  • Category listing pages
  • Product pages
  • Search results
  • Product widgets

2. Blocks add-to-cart (backend)

First layer: around plugin on Magento\Checkout\Controller\Cart\Add::execute

  • AJAX requests: responds with JSON error: true and the configured message
  • Standard requests: redirects to referer with error message in message manager

Second layer: before plugin on Magento\Quote\Model\Quote::addProduct

  • Throws LocalizedException with the message (plain text)
  • Covers any entry point using the Quote model directly

3. Blocks checkout (optional)

If "Also Disable Checkout" is set to Yes:

  • around plugin on Magento\Checkout\Controller\Index\Index::execute
  • around plugin on Magento\Checkout\Controller\Onepage\Index::execute
  • Redirects to cart with error message

4. Blocks REST API / GraphQL

before plugin on Magento\Quote\Api\CartItemRepositoryInterface::save

  • Throws LocalizedException blocking item creation via API

5. Visual notification

Displays the configured message to users via:

  • Top banner: fixed at the top, dismissible, customizable colors and CSS
  • Modal popup: centered on screen, appears once per session, with "Got it" button

Behavior when disabled

When Enable = No:

  • No plugin logic is executed (immediate early return)
  • No CSS or JS is injected
  • Banner and modal templates are not rendered
  • Performance impact: zero

The module is 100% reversible: simply set Enable = No and flush cache, everything returns to normal. No database tables are modified, no crons or observers are created.


Technical architecture

File structure

rollpix/module-disable-sales/   (repo root)
β”œβ”€β”€ registration.php
β”œβ”€β”€ composer.json
β”œβ”€β”€ etc/
β”‚   β”œβ”€β”€ module.xml
β”‚   β”œβ”€β”€ di.xml                          # Global plugins (API, Quote)
β”‚   β”œβ”€β”€ config.xml                      # Default values
β”‚   β”œβ”€β”€ acl.xml                         # ACL resource
β”‚   β”œβ”€β”€ frontend/
β”‚   β”‚   └── di.xml                      # Frontend plugins (Cart, Checkout)
β”‚   └── adminhtml/
β”‚       └── system.xml                  # Admin configuration
β”œβ”€β”€ i18n/
β”‚   └── es_AR.csv                       # Spanish (Argentina) translation
β”œβ”€β”€ Model/
β”‚   └── Config.php                      # Config reading via ScopeConfig
β”œβ”€β”€ Plugin/
β”‚   β”œβ”€β”€ Cart/
β”‚   β”‚   └── AddPlugin.php              # Blocks Cart\Add::execute
β”‚   β”œβ”€β”€ Quote/
β”‚   β”‚   └── AddProductPlugin.php       # Blocks Quote::addProduct
β”‚   β”œβ”€β”€ Checkout/
β”‚   β”‚   └── DisableCheckoutPlugin.php  # Blocks checkout access
β”‚   └── Api/
β”‚       └── CartItemRepositoryPlugin.php # Blocks REST API/GraphQL
β”œβ”€β”€ ViewModel/
β”‚   └── SalesStatus.php                # Exposes config to frontend
β”œβ”€β”€ view/
β”‚   └── frontend/
β”‚       β”œβ”€β”€ layout/
β”‚       β”‚   └── default.xml            # Injects blocks on all pages
β”‚       β”œβ”€β”€ templates/
β”‚       β”‚   β”œβ”€β”€ banner.phtml           # Top banner template
β”‚       β”‚   └── modal.phtml            # Modal popup template
β”‚       └── web/
β”‚           └── js/
β”‚               └── disable-sales-modal.js  # Modal JS (RequireJS)
└── README.md

Plugins

| Plugin | Type | Scope | Intercepted class | |---|---|---|---| | AddPlugin | around | frontend | Magento\Checkout\Controller\Cart\Add | | AddProductPlugin | before | global | Magento\Quote\Model\Quote | | DisableCheckoutPlugin | around | frontend | Magento\Checkout\Controller\Index\Index / Onepage\Index | | CartItemRepositoryPlugin | before | global | Magento\Quote\Api\CartItemRepositoryInterface |

ViewModel

Rollpix\DisableSales\ViewModel\SalesStatus exposes to frontend:

  • isDisabled(): bool
  • getMessage(): string
  • isBannerEnabled() / isModalEnabled(): bool
  • getBannerBgColor() / getBannerTextColor() / getBannerCustomCss(): string
  • getModalBgColor() / getModalTextColor() / getModalCustomCss(): string

ACL

Resource: Rollpix_DisableSales::config under Magento_Config::config


Manual testing guide

  1. Enable the module in admin (Enable = Yes) β†’ Save configuration β†’ Flush cache

    • Verify "Add to Cart" buttons disappear on category, product, and search pages
    • Verify the top banner appears (if enabled)
    • Verify the modal appears (if enabled)
  2. Try adding to cart via direct URL (/checkout/cart/add/product/ID/)

    • Verify it is blocked and shows the error message
  3. Try accessing checkout with products in cart

    • Verify it redirects to cart with error message
  4. Disable the module (Enable = No) β†’ Flush cache

    • Verify everything returns to normal
  5. Change message, colors and CSS β†’ Flush cache

    • Verify changes are reflected on the frontend
  6. Test banner close button (X)

    • Verify it doesn't show again when navigating (localStorage)
  7. Test modal in incognito mode

    • Verify it appears once and doesn't reappear in the session (sessionStorage)
  8. Test banner + modal together

    • Enable both and verify they coexist correctly

Uninstall

bin/magento module:disable Rollpix_DisableSales
bin/magento setup:upgrade
bin/magento cache:flush

If installed via composer, run composer remove rollpix/module-disable-sales. If installed manually, remove the app/code/Rollpix/DisableSales folder.

No database tables are created or modified. No residue left behind.


License

MIT

This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.