πŸ“Š State of Magento 2025 β†’

The Home for Magento 2 Excellence

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

619 Modules
409 Ready
209 Need Help
πŸ† Leaderboard
Actively Maintained v1.1.7

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.

2
Downloads
Below average
0
GitHub Stars
1d ago
Last Release
0
Open Issues
Build Passing
Ready to install

Build Tests

Composer Install
DI Compile
Templates

Code Quality

CS Coding Standard
3 errors , 49 warnings
L1 PHPStan

Tested on Magento 2.4.8-p3

Recent Test History

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

v1.1.7 on Magento 2.4.8-p3
Mar 4, 2026
v1.1.6 on Magento 2.4.8-p3
Mar 3, 2026
v1.1.1 on Magento 2.4.8-p3
Mar 3, 2026
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.

Supports restricting sales by customer group, so you can block purchases for specific groups while allowing others to continue buying.

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 | | Restrict to Customer Groups | Multiselect | (empty) | Select which customer groups are restricted. If empty, all groups are restricted (backward compatible). Includes "NOT LOGGED IN" for guest users |

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.

Customer Group Filtering

When one or more customer groups are selected:

  • Only those groups will have sales disabled. Other groups can purchase normally.
  • The frontend uses JavaScript (via Magento's customerData) to determine the customer's group and show/hide add-to-cart buttons and notifications dynamically. This is fully compatible with Full Page Cache (FPC).
  • If "NOT LOGGED IN" (group 0) is selected, guests will see buttons hidden and the banner/modal (if enabled).
  • Server-side plugins always enforce the restriction regardless of frontend behavior.

When no groups are selected (empty), the module works in legacy mode: sales are disabled for everyone using server-side CSS, identical to v1.0.x behavior.

Top Banner

| Field | Type | Default | Description | |---|---|---|---| | Show Top Banner | Yes/No | Yes | Display a dismissible banner at the top of the page | | Show Only After Login | Yes/No | No | Only show the banner after the customer logs in. Guests won't see it even if their group is restricted | | 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). The dismissed state resets automatically when the customer logs in or out.

Modal Popup

| Field | Type | Default | Description | |---|---|---|---| | Show Modal | Yes/No | No | Display a modal popup once per session | | Show Only After Login | Yes/No | No | Only show the modal after the customer logs in | | 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

Without group filter (legacy mode): Conditional inline CSS hides .action.tocart and #product-addtocart-button buttons on all pages.

With group filter: JavaScript dynamically injects/removes a <style> tag based on the customer's group (determined via customerData). This approach is FPC-compatible.

Affected pages:

  • 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

  • Checks the customer's group against the restricted list
  • AJAX requests: responds with HTTP 400 JSON containing the configured message
  • Standard requests: redirects to referer with error message in message manager

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

  • Checks the quote's customer group against the restricted list
  • 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
  • Checks the customer's group before blocking
  • Redirects to cart with error message

4. Blocks REST API / GraphQL

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

  • Loads the quote to determine customer group
  • Throws LocalizedException blocking item creation via API for restricted groups

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

Both support the "Show Only After Login" option and customer group filtering.


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, CustomerData)
β”‚   └── adminhtml/
β”‚       └── system.xml                  # Admin configuration
β”œβ”€β”€ i18n/
β”‚   └── es_AR.csv                       # Spanish (Argentina) translation
β”œβ”€β”€ Model/
β”‚   β”œβ”€β”€ Config.php                      # Config reading via ScopeConfig
β”‚   └── Config/
β”‚       └── Source/
β”‚           └── CustomerGroup.php       # Source model for customer group multiselect
β”œβ”€β”€ 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
β”‚   └── CustomerData/
β”‚       └── CustomerPlugin.php          # Adds group_id to customer section data
β”œβ”€β”€ ViewModel/
β”‚   └── SalesStatus.php                # Exposes config to frontend
β”œβ”€β”€ view/
β”‚   └── frontend/
β”‚       β”œβ”€β”€ layout/
β”‚       β”‚   └── default.xml            # Injects blocks on all pages
β”‚       β”œβ”€β”€ templates/
β”‚       β”‚   β”œβ”€β”€ banner.phtml           # Top banner template (two-mode rendering)
β”‚       β”‚   └── modal.phtml            # Modal popup template (two-mode rendering)
β”‚       └── web/
β”‚           └── js/
β”‚               β”œβ”€β”€ disable-sales-modal.js        # Modal JS (RequireJS)
β”‚               └── disable-sales-group-filter.js  # Group-based restriction JS
└── 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 | | CustomerPlugin | after | frontend | Magento\Customer\CustomerData\Customer |

ViewModel

Rollpix\DisableSales\ViewModel\SalesStatus exposes to frontend:

  • isDisabled(): bool
  • getMessage(): string
  • isBannerEnabled() / isModalEnabled(): bool
  • getBannerBgColor() / getBannerTextColor() / getBannerCustomCss(): string
  • getModalBgColor() / getModalTextColor() / getModalCustomCss(): string
  • hasCustomerGroupFilter(): bool
  • getRestrictedCustomerGroupsJson(): string (JSON array of group IDs)
  • isBannerShowOnLogin() / isModalShowOnLogin(): bool

ACL

Resource: Rollpix_DisableSales::config under Magento_Config::config


Manual testing guide

Basic functionality

  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

Customer group filtering

  1. Select specific groups (e.g., "General" and "NOT LOGGED IN") β†’ Save β†’ Flush cache

    • As a guest: verify buttons are hidden and banner/modal appear
    • Log in as a user in the "General" group: verify buttons are hidden
    • Log in as a user in a non-restricted group (e.g., "Wholesale"): verify buttons are visible and no banner/modal
  2. Test login/logout transitions

    • Start as guest (restricted) β†’ log in as non-restricted β†’ verify buttons become visible without page refresh
    • Start as guest (not restricted) β†’ log in as restricted β†’ verify buttons become hidden
  3. Test "Show Only After Login" for banner and/or modal

    • Enable the option β†’ as guest, verify banner/modal don't appear
    • Log in as a restricted user β†’ verify banner/modal appear

Visual customization

  1. Change message, colors and CSS β†’ Flush cache

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

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

    • Verify it appears once and doesn't reappear in the session (sessionStorage)
  4. 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.