Payload

Variables

Nested objects are supported. Can be used in headers and payload.

Examples:

{{$prop1}}

{{$objectName1.prop1}}

{{$objectName1.objectName2.prop1}}

{{$objectName1.functionName()}}


<items>{{for $item in $items}}

  <item>

    <sku>{{ $item.sku }}</sku>

    <qty>{{ $item.productAggregate.qty_available }}</qty>

    <eta>{{ $item.productAggregate.eta }}</eta>

  </item> {{next item}}

</items> 

Loops

$item is a freely assignable variable name to reference each item in the array.

$items is a method or property of $model which returns an array.

$_item_count is current loop iteration.

$_item_index is current loop index.

After next, the freely assignable name should be set (in this case "item"). This enables nested loops.

Example:

{{for $item in $items}}

 {{if $_item_count > 1}},{{/if}}

  { "prop1": "{{ $item.prop1 }}", "prop2": "{{ $item.prop2 }}" }

{{next item}}

Conditions

Uses a safe Eval Math class for executing the expression.

$prop1, $prop2 are properties of $model.

Example:

{{if $prop1 > 2 OR $prop2 == "TEST"}}

      {{ $prop1 }}

{{/if}}

Nested IF is NOT SUPPORTED

Printer metadata based on warehouse packingtable

If multiple packing tables exist within a warehouse and particular printer metadata is part of the payload call the following variable example:

{{ $getCurrentUser().getSelectedPackingtable().getPrinterForTypeName("A6").metadata }}

If a printertype A6 is added to a packing table and the current user is packing at this table, print jobs can be send to this printer.

Random numbers

Examples:

{{random_bytes 16}}

{{now d-m-Y H:i:s}}

random_bytes() is cryptographic secure. The amount of bytes determines the uniqueness.

As a rule you can take 16 bytes (128 bits) or more is high enough entropy. 

random_bytes() can't be used for UUID or any other standard.

See  https://www.php.net/manual/en/function.date.php  for Now formats.

Encode

Any text in the webhook headers and in payload is encodable in base64, hash, utf8, date or quoted-printable:

{{encoder [option]}}text to be encoded{{/encoder}} 

Examples:

{{base64}}Encode me in base64{{/base64}}

{{hash sha256}}Hashtext{{/hash}}

{{hash sha1}}Hashtext{{/hash}}

{{hash md5}}Hashtext{{/hash}}

{{hash crc32}}Hashtext{{/hash}}

{{date [format]}}date value{{/date}}

Date options can be found here: https://www.php.net/manual/en/function.date.php 

Date fields like the created_at field set on orders can be calculated from GMT/UTC+0 back to local.

{{date Y-m-d H:i:s @ Europe/Amsterdam}}2020-04-22 13:34:28{{/date}}


outputs: 2020-04-22 15:34:28