product_stocks_log

Triggered before saving a product stock log entry.

Shop-Script

Input (passed by reference)

$params['data'] array Information to be added to the product stock log as an array with the following keys:
$params['data']['product_id'] int Product ID.
$params['data']['sku_id'] int Product variant ID.
$params['data']['stock_id'] int ID of the stock on which the product variant quantity is being updated.
$params['data']['before_count'] float Product variant quantity before the update.
$params['data']['after_count'] float Product variant quantity after the update.
$params['data']['diff_count'] float Product variant quantity delta.
$params['data']['datetime'] datetime Product stock log entry adding date and time.
$params['data']['description'] string|null Optional log entry description.
$params['data']['type'] string Optional log update context type name.
… your plugin code …

Output

Shop-Script

Plugin code example

PHP

public function productStocksLog(&$params)
{
    if (empty($params['data']['description'])) {
        $params['data']['description'] = sprintf('Quantity change for stock #%d.', $params['data']['stock_id']);
    }
}