Docs & Guides
How To Construct A Rule
15 min
as established in our first getting started https //paccurate readme io/docs/getting started article, the key elements to cartonizing with paccurate are items and boxes with paccurate, you can configure your requests to handle sophisticated packing requirements locking orientation, excluding items from containers or other items, or defining pack as is (aka ship in own container) are just a few examples of rules that can be processed in each request in this article, we’ll cover how to build and apply rules for packing paccurate builds rules on a per item level a rule denotes a relationship between an item and a target — that target is either another item, a carton, or even itself paccurate rules use an item , a target , an operation , and options we’ll be exploring how to select items and their targets in the sections below selecting items for a rule there are three ways to define an item in a rule itemrefid , itemsequence , and itemmatch there are implications to each approach, which we will investigate below using ref ids an item's refid is typically a unique identifier for that item using the item's refid is a straightforward way of specific exactly which item the rule needs to be applied { 	"itemrefid" 11, 	"operation" "exclude all" } the rule above uses itemrefid — it means items in the request with the refid of 11 can only be packed with items that share that refid (because we are using the “exclude all” operation in the example) 🚧 important refid is not a required attribute of all items, and it must be an integer when provided using this rule when numeric refids are not present in the request will prevent the rule from being applied for customers with a smaller set of skus and requiring basic rule assignment, itemrefid is a simple, straightforward way of assigning rules to an item using sequence paccurate items support the inclusion of a sequence attribute this can be used for a number of things, including rule targeting it can be helpful to consider an item's sequence as a category it is a string value that is not exclusive from item to item { 	"itemsequence" "a100", 	"operation" "pack as is" } in the rule above, we are targeting any item with the sequence value of a100 using the itemsequence approach to targeting items is helpful when you have a handful of product categories (sequences) that share specific packing behavior in this case, the "pack as is" rule would make any item with the sequence a100 be packed in its own outer box, no matter what both the itemsequence and itemrefid methods of targeting items work well when your item refs and sequences are of a manageable size, or you are able to intelligently create rules on the fly for more complex categories and and item targeting however, you may want to use itemmatch , which we will cover next item match for more powerful item targeting, itemmatch is essential it allows you to create rules that look at parts of attributes (name or sequence), and even invert the items you are targeting (think "every item that's not polybag eligible", or "any item whose sequence begins with hm") there are 5 attributes to an itemmatch object all , property , expression , expressions , and negate all the all attribute is a boolean ; setting all\ true would apply the rule to all items in the request { "itemmatch" { "all"\ true 	}, "operation" "pack as is" } in the above example, all items in the order would have the pack as is rule applied to them, and ship in a carton of the item's dimensions another example use case where using all would be useful is simulating donnage or packing material if you know that all of your items must have 1/4" of packing material on them , you could use an alternate dimensions operation to add the extra length/width/height on all items, and paccurate would pack using those changes property the property attribute is used much more commonly than all it tells the match function where to look for the rule the options for property are name and sequence expression the expression attribute defines what to look for in the specified property it is a string to search for in the property { 	"itemmatch" { "property" "name", "expression" "heavy" }, "operation" "pack as is" } in the above example, any item that has "heavy" in its name will be packed as is and shipped in its own packaging items named "dog food heavy" or "cat litter heavy" would have the above rule applied we see customers using this to build item categories using either the name or the sequence 📘 note expressions are case sensitive, so you may want to review your item names and/or sequences and make sure any instance of the expression is captured expressions if you have a rule that applies to multiple categories, the expressions attribute should be used it works the same way as expression but supports multiple values { 	"itemmatch" { "property" "name", "expressions" \["heavy", "xl", "oversize"] }, "operation" "pack as is" } similar to the previous example, this rule would apply the "pack as is" behavior to items such as "cat food xl", "crate oversize", and "dog food heavy" negate the negate option is a way of inverting the match rule it is effectively saying "anything that does not match the expression in this property" should have this rule applied a practical application of this logic is carton type exclusion { 	"itemmatch" { "property" "sequence", "expression" "baggable", "negate"\ true }, "operation" "exclude", "targetboxrefids" \[800,900] } the rule above is excluding non baggable items (items without "baggable" in their sequence property) from two types of cartons (in this case, bags) with the refids of 800 and 900 rule targets while there are numerous ways to select an item for a rule, defining the rule's target is a bit more straightforward since rule targets are exclusively used for the exclude operation, the target defines what the item is being excluded from the options for rule targets are targetitemrefids , targetitemsequences , and targetboxrefids all three are arrays item refids { 	"itemrefid" 1, "targetitemrefids" \[2, 3, 4], "operation" "exclude" } here, we are excluding an item with the refid of 1 from being packed with items of refids 2, 3, or 4 the targetitemrefids array must only contain integers item sequences { 	"itemrefid" 1, "targetitemsequences" \["hm300", "un835", "1100"], "operation" "exclude" } similar to the refid approach, we are specifying the sequences of the items of which we want item with refid 1 to be excluded the targetitemsequences array must only contain strings box refids { 	"itemrefid" 1, "targetboxrefids" \[800, 900, 1100], "operation" "exclude" } in order to exclude items from being packed in specific boxes, we use the parameter targetboxrefids which is an array of integers that represent specific boxes (or any type of container) this can be used to exclude items from mailers, branded boxes, or any box type provided to the request that may not apply to all items in a given request conclusion to recap the first step in building rules is determining which items the rules apply to, along with the target of the rule (if the item has specific exclusions from a target) once these relationships for the rule have been determined, the next step is defining what the rule does we'll cover operations and options in their own article