Plugin Architecture

Many components of Zone Based Shipping are built about a standardised plugin architecture, similar to that used throughout the Magic Data family of addons and Universal Content Puller. 

ZBS uses plugins for:

  • Cost Basis measures
  • Units
  • Comparisons
  • Order Address Items
  • Delivery Splits

For extreme situations where you need a bit more than ZBS can do, you can add a plugin for it!

All of these follow a very similar pattern to the Magic Data family of addons and Universal Content Puller, so I won't go into details here, save to highlight the differences.

For those familiar with such plugin architectures, the general difference is the number of methods that return section of UI text, used for help and documentation. Many of these are automatically assembled by more familiar interfaces such as getDescription(), so most new plugins only have to provide the bare minimum in a similar way to existing plugins, but the flexibility is available to override further into the base classes for specialised functionality. 

Cost Basis plugins

Most Cost Basis measures also have associated Units. So when you develop a new Cost Basis, you will either need to associate an existing set of Units, or provide an appropriate Units plugin. These Cost Basis measures are also qualified as simple_select and comparison_is_boolean. Simple_select means that the cost basis is presented in a cost rule as a simple selection of units, without the associated numeric fields a cost basis rule would normally have. Comparison_is_boolean means that it can only be used with Boolean compatible comparison plugins.

Units plugins

Units plugins are fairly simple, in most cases simply declaring conversion factors between units. However, there are some exceptions that pretend to be units. For Shipping Agents, the units are a selectable list of the available shipping agents. For Magic Data, the units are a selectable list of MD Snippets.

Delivery Split plugins

The complex part of a Delivery Split plugin is a split() method that it takes a list of products (from the cart) and returns an array of lists of products, according to whatever the splitting logic is.

Order Address Item plugins

Each plugin extracts an aspect of a customer or shipping address that is used for mapping zones. Each rule is classified as either a country_rule or secondary_rule.

Comparison plugins

Comparison plugins usually support both the comparison and its inverse. For example, the less than plugin automatically provides its inverse, greater than or equal to.

Comparison plugins are also qualified as being single_number_compatible, meaning the comparison can be used with simple numeric cost rules, and boolean_compatible, meaning the comparison can be used with boolean cost rules.


Last updated: over a year ago