public function update_inventory() { check_admin_referer('wp_ajax_shopp_update_inventory'); $restocked = shopp_product_variant_set_stock((int) $_GET['id'], (int) $_GET['stock'], 'restock'); if ($restocked) { echo '1'; exit; } else { die('0'); } }
/** * shopp_product_addon_set_stock - adjust stock or set stock level on a addon. The stock level effects low stock warning thresholds. * * @uses shopp_product_variant_set_stock() * @api * @since 1.2 * * @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. **/ function shopp_product_addon_set_stock($addon = false, $stock = 0, $action = 'adjust') { return shopp_product_variant_set_stock($addon, $stock, $action, 'addon'); }