shopp_product_addon_set_stock ( $addon, $stock, $action ) @param int/Price $addon (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 addon stock without setting the stock level, 'restock' to set both the addon stock and stock level @return bool/Price false on failure, true if Price saved, else the modified Price object.
adjust stock or set stock level on a product addon.
This function uses shopp_product_variant_set_stock().
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 media addon for software download product 6 $Addon = shopp_product_variant( array('product' => 6, 'option'=>array('Backup'=>'DVD Install Disk')), 'addon'); // Set the stock on the addon to 20 shopp_product_addon_set_stock ( $Addon->id, 20);