adjust stock or set stock level on a product, variant, or addon.

shopp_product_variant_set_stock ( $variant, $stock, $action, $context )

@param int/Price $variant (required) The priceline id to set stock/stock level on, or the Price object to change.  If Price object is specified, the object will be returned, but not saved to the database.
@param int $stock (optional default=0) The stock number to adjust/set the level to.
@param string $action (optional default=adjust) 'adjust' to set the variant stock without setting the stock level, 'restock' to set both the variant stock and stock level
@param string $context (optional default:variant) enforces the priceline is a 'product','variant', or 'addon'
@return bool/Price false on failure, true if Price saved, else the modified Price object.


adjust stock or set stock level on a product, variant, or addon.

The stock level effects low stock warning thresholds, as well as prevents out of stock items from being purchased.

Stock versus Stock Level

In Shopp 1.2, instead of a flat figure where low stock is indicated across all products, there is a low stock percentage, which will base low stock on the ratio of the current stock to the product’s stock stock level. For instance, if the the low stock threshold is 50% and the stock level is set to 20, low stock warning will appear when the product has less than 10 items.


// get the product priceline for product 2
$ProductPrice = shopp_product_variant( array('product' => 2), 'product');

// adjust the product stock to 10 without setting the stock level
shopp_product_variant_set_stock ( $ProductPrice->id, 10, 'adjust', 'product' );

See Also

You must be logged in to post a comment.

© Ingenesis Limited. Shopp™ is a registered trademark of Ingenesis Limited.