The tweak.rules rules file, unlike other rules files, has no direct effect on your checkout line-items. Instead, it is used to modify products read from your products source (usually your products file), allowing you to "tweak" their values according to user input, store conditions, or just about anything you can do in HZML.
Since you're all big boys and can deal with just jumping into an example, let's do that right now. The following tweak.rules file would cut in half the price of any item with a true SLASH field.
## tweak.rules ## Rules for tweaking product info right after Hazel reads their data ## from the standard source. ## -- ## email@example.com <Hazel-Loop Type="Products" Src="%HZH_TWEAKABLE" > <Hazel-True Token="%HZI_SLASH"> <Hazel-False Token="%HZI_SLASHED"> <Hazel-Math Value="%HZI_PRICE" OP1="/2" Type="Float" /> SKUID: %HZI_SKUID PRICE: %HZV_RESULT NOTE: Price of %HZI_NAME is SLASHED in half for a limited time! SLASHED: 1 </Hazel-False> </Hazel-True> </Hazel-Loop> ## End.
The one thing common to all tweak files is the %HZH_TWEAKABLE value. It will contain a semicolon delimited list of all SKUID Hazel feels should be "tweaked" at the time the file is processed. Above, we use a standard Hazel-Loop to loop over each of those.
Within this set of "tweakable" products, we only care about those with a true SLASH field value. Of those, we want to avoid processing the ones we've already set as SLASHED.
So, if a tweakable product is slashable and hasn't already been slashed, we do some Hazel-Math to determine the half-price (note we specify a floating point return value), then we output lines just as we would in a Hazel products file, starting with an indication of the SKUID we're setting, then subsequent lines of field values.
And it's just that easy!
HZML & HAM
CGI and You