silvershop / stock
Adds stock management to SilverShop.
Package info
github.com/silvershop/silvershop-stock
Type:silverstripe-vendormodule
pkg:composer/silvershop/stock
Requires
- php: ^8.3
- silvershop/core: ^6
- silverstripe/framework: ^6.0
Requires (Dev)
- cambis/silverstan: ^2.2
- guzzle/plugin-mock: ^3.1
- omnipay/dummy: ^3.0
- omnipay/paymentexpress: ^3.0
- phpunit/phpunit: ^11.0
- squizlabs/php_codesniffer: ^3.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Adds stock management to the SilverStripe Shop module.
Installation
composer require "silvershop/stock:dev-main"
After installing the module, rebuild the database and create your first product
warehouse in the ProductCatalogAdmin tab.
Feature Overview
This module provides a couple of additional models - ProductWarehouse,
ProductWarehouseStock. A warehouse is a concept of a location where quantity
of the stock is held. In a simple case, you may have a single ProductWarehouse
instance that contains all your stock. More complex shops may have multiple
warehouses (i.e a store and a supplier). These warehouses are managed through
the ProductCatalogAdmin panel in the CMS.
The ProductWarehouseStock object manages the relation between a Product or a
ProductVariation and contains the specific count of the product at that
particular warehouse.
After installing the module your Product edit screen will gain a Stock tab
which lists all your warehouses and the value count of the product (or
variation). Leaving a warehouse stock value as -1 implies that this warehouse
has an unlimited quantity of this product.
For a product with variations, stock is managed per variation. As well as each
variation's Stock tab, a Stock column is shown inline on the product's
Variations grid for quick single-warehouse editing (it appears once at least
one warehouse exists, and edits the first warehouse's level).
When an product is added to the users cart, the quantity is on reserved as the
current order is stored in the Order table.
To make sure that stock added to the cart is released on abandoned carts make
sure you have the CartCleanupTask task enabled as a cron job
Configuration
Unlimited stock as a checkbox (opt-in)
By default a warehouse stock value of -1 means "unlimited". That sentinel is
ambiguous where real stock can be negative or exactly -1. Enable an explicit
Unlimited boolean instead:
SilverShop\Stock\Model\ProductWarehouseStock: use_unlimited_checkbox: true
When enabled, an Unlimited checkbox column appears next to Stock on the
product's Variations grid, unlimited stock is stored in the Unlimited field
instead of Quantity = -1, and Quantity is free to be any integer. Off by
default, so existing installs are unaffected.
Migration: enabling this on an install that already uses
Quantity = -1for "unlimited" requires migrating those records toUnlimited = 1, otherwise-1becomes a real (negative) quantity and reads as out of stock.
TODO
- Allow prioritizing of warehouses within each product (i.e use warehouse X for
before warehouse Y) This should use a sortable grid field based on the
ProductWarehoueStock.