Stock enforcement message per product type

Created on 18 April 2025, 8 days ago

Is there a way to use different "out of stock" enforcement messages for different stock types? For example, I might want a book's out-of-stock message to be something like "No longer on our shelves", or a carburetor's be "Not available to install." You get the idea.

I can use a form_alter hook to add a field to the form at admin/commerce/config/stock/enforcement/settings, adding message options for one specific type to the commerce_stock_enforcement.settings configuration.

But in the actual commerce_stock_enforcement.module, the function commerce_stock_enforcement_is_order_in_stock() is hardwired to retrieve only the original setting:

$message_text = Drupal::config('commerce_stock_enforcement.settings')
          ->get('insufficient_stock_cart');

As far as I can tell, I'd actually have to patch the module, to make alternate message settings available.

Is there perhaps a better way?

πŸ’¬ Support request
Status

Active

Version

1.3

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States datawench

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024