Customizing Cartonization Using Scripts

Customizing Cartonization Using Scripts

The standard Infoplus Cartonization process is based on using real-world dimensions of your products, plus the inner dimensions of the Carton Types you have set up in Infoplus.  


However, there are times when you may need to customize how this algorithm packs your orders.  For example, some orders may not be allowed to use all of the available Carton Types.  Or you might have a business rule that says you need each unique SKU (line item) to be assigned to its own Carton.  Infoplus allows you to customize Cartonization in cases like these, using Cartonization Scripts.  Here's how they work.


Infoplus Support can help with general questions about how scripting works. For help with a specific script or its outputs, you will need to submit a Pro Services request for paid support. Pro Service request form can be found here.


Create a Cartonization Script

To create a Cartonization Script, simply navigate to the Script table in Infoplus.  Create a new Script, and choose the Script Type of Cartonization.  


For the code in a Cartonization script, there 3 functions that you must supply, each of which allows you to customize a different part of the Infoplus Cartonization process.  Note that even if you do not want to provide any custom logic in one or more of these functions, that they still need to be present in your script, and provide a default action - else you may receive errors when using the script.  

  • customizeAvailableCartons- This function allows you to customize the carton types allowed for the given order during cartonization.  In other words, if a given order isn't allowed to ship in a particular carton type, this function can be used to make that type not available.  
    • A default version of this function would be:  utils.setOutputCartonList(utils.originalCartonList);
  • customizeCartonizationCall- This function controls whether or not Infoplus should run its standard cartonization process on the given order.  If this function tells Infoplus not to run its standard cartonization process, then you must build your own cartonization output, using the customizeCartonizationOutput function. 
    • A default version of this function would be : utils.setShouldRunCartonization(true);
  • customizeCartonizationOutput- This function runs after Infoplus has ran the default cartonization process (unless customizeCartonizationCall has told Infoplus not to run it), and it allows you to customize the output of cartonization on the given order.  For example, you could split up any carton that had more than a certain number of items in it, or you could change carton types so that an order was shipping in all identical cartons.  If customizeCartonizationCall indicated that Infoplus should not run standard cartonization, then this function must fully cartonize the order - i.e., placing all contents into cartons.
    • A default version of this function would be:  utils.log("No-op on customizeCartonizationOutput");

When you create a new Cartonization Script, Infoplus will pre-populate the Code field with a comment that describes in more detail the variables and functions available in a Cartonization Script.  


Using a Cartonization Script

To use a Cartonization Script, you can select it when defining a Fulfillment Plan or running a Fulfillment Process in Infoplus.  


If you are going to be processing various orders together, some of which should, and some of which shouldn't have the script applied to them, you may need to build some logic into your script, where you look at attributes of the order object, to make decisions about what custom logic to apply (or not to apply).


You can also specify the usage of a Cartonization Script if you are setting up a trigger to run pre cartonization on your orders.  This will help you ensure that the pre cartonization estimated cartonization plan will match the true cartonization plan that is used when your orders are fulfilled:


Example Cartonization Scripts

Only use Special Carton Types for Special Orders

In this example script, there is a certain special order type, which is only allowed to use a special type of carton type.  Also, these special cartons cannot be used for other order sources.  This script will check the order's orderSource, to see if it is a special order or not, and will customize the list of available carton types based on whether those cartonTypes have the the isSpecialCarton custom field set on them.

Pack Each Line Item in its Own Carton

In this script, we are trying to meet the requirement from a partner that each line item on an order be packed in its own carton.  A caveat to this script is the fact that we will not necessarily be choosing an optimally sized carton, nor will we recognize if too many items are being packed into a single carton.