shopp_product_variant_set_inventory()

turn on/off inventory tracking, set stock level, and stock keeping unit (SKU) on a product, variant, or addon.

shopp_product_variant_set_inventory ( $variant, $flag, $settings, $context )

@param int/Price $variant (required) The priceline id to setup the inventory tracking on, or the Price object to change.  If Price object is specified, the object will be returned, but not saved to the database.
@param bool $flag (optional default:false) true for on, false for off. Turns on or off the inventory tracking on the variant.  If false, settings are ignored.
@param array $settings array of inventory settings (stock => int, sku => sting)
@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.

Description

turn on/off inventory tracking, set stock level, and stock keeping unit (SKU) on a product, variant, or addon.

This function uses shopp_product_variant_set_stock() to set the stock level on a product, variant, or addon.

Example

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

// turn on inventory tracking on product 2
shopp_product_variant_set_inventory ( $ProductPrice->id, true, array('stock'=>15, 'sku'=>'MYPRODUCTSKU'), 'product' );

See Also

You must be logged in to post a comment.

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

Skip to toolbar