The inventory plugin allows Hazel to keep track of the stock levels of the products offered in your catalog. It uses a simple file alongside your existing products file to keep track of the data, decrementing the quantity remaining when an item is ordered from your catalog.
The inventory plugin adds no new actions to your Hazel. What it does add is an HZML token to each product: %HZI_STOCK. This field represents how many of the given item remain in your inventory.
While the plugin does other things (see configuration below), the weight of its functionality lies in that simple token. With it, you can use HZML conditionals to display messages to the shopper about current stock levels.
Netsville will have sent you a package containing the plugin itself. Create a hazel-cgi/plugins directory (that is, a plugins directory inside the directory containing your current hazel.cgi) and upload the plugin (a file ending in .so) there.
Next, you'll create an inventory.txt file. Each line will contain a product SKUID (as listed in your products file), a colon, and a number representing how many of the item you have in stock. Here's a simple inventory file:
COCONUT:13 BANANA:5 UGLYFRUIT:12
The store to whom the above inventory file belongs currently has thirteen coconuts, five bananas, and twelve ugly fruits in stock.
The following hazel.config fields are used by the members plugin. You can copy all of them and paste into the bottom of your hazel.config if you like, editing them if necessary. (The defaults are reasonable.)
## If set, STOCK_ADJUST_ACTIONS is interpreted as a semicolon-delimited ## list of Hazel actions which will cause your inventory levels to be ## adjusted. It can be used, for example, to exclude finishing actions ## which aren't yet finished, such as one to printed out and faxed. #STOCK_ADJUST_ACTIONS: FINISH ## STOCK_MIN is the minimum allowed value for a product stock level. It ## defaults to 0. You probably won't want to change this unless you're ## sure you always maintain stock at a certain level above zero, or if ## you want negative values in your inventory file to reflect the actual ## number purchased over that available. #STOCK_MIN: 0 ## STOCK_FIELDNAME can be used to override the name of the %HZI_STOCK ## HZML token. #STOCK_FIELDNAME: STOCK ## If STOCK_AFFECTS_MAXQ is set, each product's MAXQ field will be set ## to its stock level, or an existing MAXQ, whichever is less. #STOCK_AFFECTS_MAXQ:0 ## STOCK_DISCONTINUED_FIELD indicates the name of a product field which ## indicates that no more of the product will be ordered. If that field ## is set on a product, its MAXQ will be forced to the current stock level. #STOCK_DISCONTINUED_FIELD:
The first step when using the inventory plugin is to insert the new %HZI_STOCK token somewhere. A good starting place is in your hazel-cat/templates/view.html template. Put it within the main "selected" loop on that template, eg. as <em>%HZI_STOCK remaining</em>.
Add an item, place an order, then come back and try adding it again. The stock level should have been reduced by the number you ordered.
If you receive errors such as "unknown Hazel action", then the plugin may not be installed correctly. Send your Hazel an action=showreg. The plugin should appear near the bottom, along with its internal version-id and build date.
If you don't see it, it might be time to call Netsville. We'll be glad to help you get it running.