Experimental project

This is a sandbox project, which contains experimental code for developer use only.

This Commere Stock contrib module uses hook_base_info_alter to add three base fields to any commerce_product_variation:

- stock_field (a commerce_field_stock) which is managed by the commerce stock api.
- allow_no_stock_sale (boolean)
- no_stock_message (textfield)

The module then overrides the default commerce_stock StockAvailablityManager to consult the above fields to see if it has stock, and if not, is it still allowed to make available the requested amount of stock.

The module overrides commerce stock's OrderEventSubscriber to take into account the possibility that the items in an order might not all go back into stock if the order is cancelled or deleted.

Also provided is a Stock level formatter that takes into account the above fields when presenting the stock level to the customer, as follows:

stock level > 10: "Availability: In Stock"
Stock level 1-9: "Availability: N remaining"
Stock level 0 and !allow_no_stock_sale: "Availability: Out of Stock"
Stock level 0 and allow_no_stock_sale: "Availability: [no_stock_message]"

This module could be used as-is or as an example of a module implementing a custom business logic for backordering.

NOTE that this module, as of October 12 2017, requries this drupalcommerce PR https://github.com/drupalcommerce/commerce/pull/593 which you an apply as a patch: https://patch-diff.githubusercontent.com/raw/drupalcommerce/commerce/pul...

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • caution Maintenance fixes only
    Considered feature-complete by its maintainers.
  • Project categories: E-commerce
  • Created by ransomweaver on , updated