Summary
The english version of the documentation is not up to date. If you can read french, please use the french version.
I have not enough time to translate the documentation in english. If somebody wants to translate the documentation in english or in an other language, please contact owebia.
- Introduction
- The label : `label`
- Shipping fees : `fees`
- Introduction to formulas
- Use of rate tables
- Make a copy of a property of another method
- Special functions in formulas
- Usage of product's attributes or options (stock data added in version 2.3.2)
- Usage of foreach loops (added in version 2.1.7)
- Usage of Magento's custom variables (added in version 2.2.7)
- The conditions : `conditions`
- The destination : `destination`
- The code : `code`
- The description : `description`
- The origin : `origin`
- Customer groups : `customer_groups`
- Tracking URL : `tracking_url`
- Comments
- Changelog
Introduction
If you have a question, use the following topic : http://www.magentocommerce.com/boards/viewthread/38223/
The configuration syntax is similar to JSON syntax.
Example :
{
label: "National",
destination: "AD,FR,MC",
conditions: "{cart.price_excluding_tax}<1000.00",
fees: "1.30 + {table {cart.weight} in 0.5:5.30, 1.0:6.50, 2.0:7.40, 3.0:8.30, 5.0:10.10}",
}
The character `#` at the beginning of a line indicates a comment.
A configuration element begins with the character `{` and ends with `}`.
A configuration element contains several properties associated with values.
The properties are alphanumeric (a-z0-9_), the separator property/value is the character `:`, values are numeric, boolean or string delimited by quotation marks. At the end of a line, a comma is the separator between the various properties.
List of properties:
- label: name (label)
- description: description (only visible if template show it)
- code: shipping method's code (optional but if specified it must be unique)
- enabled: configuration bloc activated or not (ex: true or false)
- fees: shipping fees (ex: "15.00" or "{table {cart.weight} in 0.5:5.30, 1.0:6.50}" or "100 * {cart.weight}")
- conditions: activation conditions (ex: "{cart.weight}>=1.0" or "{cart.price_excluding_tax}<100.00" or "({cart.weight}<=1.0) and ({cart.weight}>3.0) and {free_shipping}" or "{count products where product.attribute.color=='Bleu'}>1 or {count products where product.option.size=='2m'}>2")
- destination: countries (possibly regions) authorized in destination (ex: "FR,DE,US" or "FR(2A,2B,25000)" or "FR-(2A,2B)" or "FR(01,02,39600),CH,DE")
- origin: countries (possibly regions) authorized in origin (ex: "FR,DE,US" or "FR(2A,2B,25000)" or "FR-(2A,2B)" or "FR(01,02,39600),CH,DE")
- customer_groups: customer groups authorized (ex: "NOT LOGGED IN,Retailer" or "0,3")
The label : `label`
This will be the name given to the shipping method.
Elements such as the weight of goods can be inserted in the label.
To do this, use the following variables:
- {destination.country.name}: destination country name
- {destination.country.code}: destination country code
- {destination.region.code}: destination region code
- {destination.postcode}: destination postcode
- {origin.country.name}: origin country name
- {origin.country.code}: origin country code
- {origin.region.code}: origin region code
- {origin.postcode}: origin postcode
- {cart.weight}: weight of goods
- {cart.weight.unit}: weight unit
- {cart.quantity}: products quantity
- {cart.price_including_tax}: price including tax
- {cart.price_excluding_tax}: price excluding tax
- {store.code}: store code
- {store.name}: store name
- {store.address}: store address
- {store.phone}: store phone
- {date.timestamp}: UNIX timestamp of current date
- {date.year}: year of current date
- {date.month}: month of current date
- {date.day}: day of current date
- {date.hour}: hour of current date
- {date.minute}: minute of current date
- {date.second}: second of current date
This line will display for example "Colissimo (3.0kg / France)".
Shipping fees : `fees`
The property `fees` is specified as a formula (see introduction to formulas).
fees: 10.00,
# Rates table
fees: "{table {cart.weight} in 0.5:5.30, 1.0:6.50}",
# Formula
fees: "0.1 * {cart.price_excluding_tax} + 10.00",
# Combination
fees: "0.1 * {cart.price_excluding_tax} + {table {cart.weight} in 0.5:5.30, 1.0:6.50} + 10.00",
Introduction to formulas
Properties `fees` and `conditions` are specified as formulas.
Mathematical signs available:
- operators: *, /, + et -
- modulo: %
- brackets: ( et )
- boolean operators &&, and, ||, or, ==, <, >, <=, >=
- binary operators & et |
- operators group C ? X : Y (ex: "{cart.price_exluding_tax}>100 ? 15*{cart.weight} : 20*{cart.weight}")
Functions available:
- rounds: round(x), floor(x), ceil(x)
- absolute value: abs(x)
- maximum: max(x,y)
- minimum: min(x,y)
- random integer: rand(min,max)
- power: pow(x,puissance)
- PI number: pi()
- square root: sqrt(x)
- logarithm: log(x) for the natural logarithm or log(x,base)
- exponential: exp(x)
Ability to use advanced features like: casting to integer (int) casting to floating number (float), comparison with null or boolean values true and false.
Variables available:
- {cart.weight}: full package weight
- {cart.price_including_tax}: price including tax
- {cart.price_excluding_tax}: price excluding tax
- {cart.quantity}: items count in cart
- {date.timestamp}: UNIX timestamp of current date
- {date.year}: year of current date
- {date.month}: month of current date
- {date.day}: day of current date
- {date.hour}: hour of current date
- {date.minute}: minute of current date
- {date.second}: second of current date
- {free_shipping}: free shipping (offered by a Magento rule) [true/false]
You can put spaces and line returns in formulas (to air).
You can also use advanced features such as rates tables, copy of a property of another method, special functions, usage of product's attributes and options or usage of custom variables.
Usage of rates tables
In a table, you can include or exclude a limit value with characters '[' and ']' :
fees: "{table {cart.weight} in 1.0]:5.00}",
# Upper limit 1.0 excluded
fees: "{table {cart.weight} in 1.0[:5.00}",
In a table, you must specify the reference value. For this, we can use one of the available variables.
You can also use a formula to define another reference variable.
fees: "{table {cart.weight} in 0.5:5.30, 1.0:6.50}",
# Limit values are compared to the items count
fees: "{table {cart.quantity} in 10:5.30, 20:6.50}",
# Limit values are compared to the prixe including tax
fees: "{table {cart.price_including_tax} in 15.00:5.30, 30.00:6.50}",
# Limit values are compared to the prixe excluding tax
fees: "{table {cart.price_excluding_tax} in 15.00:5.30, 30.00:6.50}",
# Limit values are compared to an user defined reference value
fees: "{table ceil({cart.weight}/10) in 1:5.30, 2:6.50}",
Make a copy of a property of another method
It is possible to make a copy of a property in another using the syntax below.
You can use this technique in the properties 'conditions', 'fees', 'enabled', 'label', 'description', 'destination', 'origin', 'customer_groups' and 'tracking_url' but not in property 'code'.
{
code: "colissimo",
label: "Colissimo",
destination: "AD,FR,MC",
conditions: "{cart.price_excluding_tax}<1000.00",
fees: "1.30 + {table {cart.weight} in 0.5:5.30, 1.0:6.50, 2.0:7.40, 3.0:8.30, 5.0:10.10}",
}
...
# Copy conditions of another method
conditions: "({colissimo.conditions}) and ({cart.weight}>10.0)",
...
# Copy shipping fees of another method
fees: "({colissimo.fees}) + 15.00",
...
Special functions in formulas
You can use special functions in formulas.
List of special functions :
- min(x,y) : calculate the minimum of several values (possibly more than two values). If one value is null, it is ignored.
- max(x,y) : calculate the maximum of several values (possibly more than two values). If one value is null, it is ignored.
# and supplements for faster shipping methods
{
code: "courrier_suivi",
label: "Courrier suivi",
destination: "FR",
conditions: "{cart.price_including_tax}<80",
fees: "{table {cart.weight} in 0.050:2.21, 0.100:2.77, 0.500:4.60}",
}
{
code: "courrier_suivi_offert",
label: "Free shipping - Courrier suivi",
destination: "{courrier_suivi.destination}",
conditions: "{cart.price_including_tax}>=80 and {cart.weight}<=0.500",
fees: 0.00,
}
{
code: "lettre_recommandee",
label: "Lettre Recommandée",
destination: "FR",
conditions: "{cart.price_including_tax}<80",
fees: "{TABLE {cart.weight} IN 0.050:4.3,0.100:4.75,0.250:5.62,0.500:6.42,1.000:7.32,2.000:8.56,10.000:10.30}",
}
{
code: "lettre_recommandee_offert",
label: "Free shipping - Lettre Recommandée",
destination: "{lettre_recommandee.destination}",
conditions: "{cart.price_including_tax}>=80 and {cart.weight}>0.500 and {cart.weight}<=10.000",
fees: 0.00,
}
{
code: "supplement_lettre_recommandee",
label: "Lettre Recommandée supplement",
destination: "{lettre_recommandee.destination}",
conditions: "{courrier_suivi_offert.conditions}",
fees: "{lettre_recommandee.fees} - {courrier_suivi.fees}",
}
{
code: "colissimo",
label: "Colissimo",
destination: "FR",
conditions: "{cart.price_including_tax}<80",
fees: "{table {cart.weight} in 0.3:8.7,0.8:9.9,1.8:10.85,2.8:11.8,4.8:13.7,6.8:15.6,9.8:18.45,14.8:20.45,29.8:26.45}",
}
{
code: "colissimo_offert",
label: "Free shipping - Colissimo",
destination: "{colissimo.destination}",
conditions: "{cart.price_including_tax}>=80 and {cart.weight}>10 and {cart.weight}<=29.8",
fees: 0.00,
}
{
code: "supplement_colissimo",
label: "Colissimo supplement",
destination: "{colissimo.destination}",
conditions: "{courrier_suivi_offert.conditions} or {lettre_recommandee_offert.conditions}",
fees: "{colissimo.fees} - min({courrier_suivi.fees},{lettre_recommandee.fees})",
}
{
code: "chronopost",
label: "Chronopost",
destination: "FR",
conditions: "{cart.price_including_tax}<80",
fees: "{TABLE {cart.weight} IN 1:13.29, 2:13.99, 3:18.4, 4:19.24, 5:20.08, 6:20.92, 7:21.76, 8:22.6, 9:23.44, 10:24.28, 15:28.48, 20:32.68, 25:36.88, 30:41.08}",
}
{
code: "chronopost_offert",
label: "Free shipping - Chronopost",
destination: "FR",
conditions: "{cart.price_including_tax}<80 and {cart.weight}>29.8 and {cart.weight}<=30",
fees: 0.00,
}
{
code: "supplement_chronopost",
label: "Chronopost supplement",
destination: "{chronopost.destination}",
conditions: "{courrier_suivi_offert.conditions} or {lettre_recommandee_offert.conditions} or {colissimo_offert.conditions}",
fees: "{chronopost.fees} - min({courrier_suivi.fees},{lettre_recommandee.fees},{colissimo.fees})",
}
Usage of product's attributes or options
It is possible to use product's attributes or options with the syntax below.
You can use this technique in the properties 'conditions' and 'fees'.
conditions: "{count products where product.attribute.color=='Bleu'}>0",
...
# If all products have the option 'size' greater or equal to '1'
conditions: "{count products where product.option.size>='1'}=={cart.quantity}",
...
# Different SKU count
conditions: "{count distinct product.attribute.sku}",
...
# The sum of all options 'size' is greater than '1'
conditions: "{sum product.option.size}>30",
...
# Count of products in stock
conditions: "{count products where product.stock.is_in_stock==true}",
...
Available prefixes list:
- count: count (always followed by 'products')
- count distinct: distinct count (always followed by a property)
- sum: sum (always followed by a property)
Available properties list:
- product.attribute.* : attribute
Interesting attributes:- sku : the sku
- name : the name
- weight : the weight
- price : the price (as filled in product's card)
- special_price : the special price (as filled in product's card)
- product.option.* : option
- product.stock.is_in_stock : product availability
- product.stock.quantity : stock quantity of the product
It's possible to specify conditions that must be met by products to be taken into account. To do this, simply add where followed by a formula.
If the property type is Yes/No, you should use true/false or 1/0 without quotes.
conditions: "{count products where product.attribute.colissimo_allowed==1}",
# or
conditions: "{count products where product.attribute.colissimo_allowed==true}",
If the property type is Drop-down and you want to make a comparison with the id rather than with the value, you must use the following syntax:
conditions: "{count products where product.attribute.color.id==1}",
Usage of foreach loops
Foreach loops can perform calculations on groups of products rather than consider all the products in the basket.
The overall result of a foreach loop is the sum of the results of each pass through the loop.
Inside a foreach loop, it is possible to use new variables:
- {selection.weight}: selection weight
- {selection.quantity}: items count in the selection
When the selection is done on the sku, each selection is composed of a single article. We can use other variables:
- {product.weight}: weight of selected product
- {product.quantity}: quantity of selected product
- {product.attribute.*}: attribute of the selected product
- {product.option.*}: option of the selected product
fees: "{foreach product.attribute.code_origin}{table {selection.weight} in 0.0:0.00, 1.0:11.00, 3.0:12.00, 5.0:13.00}{/foreach}",
# Individual calculation of shipping fees
fees: "{foreach product.attribute.sku}{product.attribute.shipping}*{product.quantity}{/foreach}",
Usage of Magento's Custom Variables
Since version 1.4.0.1 of Magento, it is possible to define custom variables.
Version 2.2.7 of Owebia Shipping allows you to use these custom variables using the following syntax:
fees: "{customvar.my_var}*5.00",
...
# The same using the standard syntax of Magento
fees: "{{customVar code=my_var}}*5.00",
...
The conditions : `conditions`
The property `conditions` is specified as a formula (see introduction to formulas) that must return a boolean value (true or false).
# From 0 to 70 including tax
conditions: "{cart.price_including_tax}<=70",
# From 0 to 70 excluding tax
conditions: "{cart.price_excluding_tax}<=70",
# From 20 excluded to 70 included
conditions: "({cart.price_excluding_tax} > 20) and ({cart.price_excluding_tax} <= 70)",
# From 10 included to 50 excluded
conditions: "({cart.price_excluding_tax} >= 10) and ({cart.price_excluding_tax} < 50)",
# Weights range
# From 0.5 excluded to 3 included
conditions: "({cart.weight} > 0.5) and ({cart.weight} <= 3.0)",
# From 1 included to 5 excluded
conditions: "({cart.weight} >= 1.0) and ({cart.weight} < 5.0)",
# Frais de port offerts
# Uniquement si frais de port offerts
conditions: "{free_shipping}",
# Uniquement si frais de port non offerts
conditions: "!{free_shipping}",
# Product's attribute or option
# If at least one product has the attribute 'color' equal to 'Blue'
conditions: "{count products where product.attribute.color=='Bleu'}>1",
# If all products have the option 'size' greater or equal to '1'
conditions: "{count products where product.option.size>='1'}=={cart.quantity}",
The destination : `destination`
The country codes used are those of Magento (it seem that they are the same as the codes ISO 3166-1 alpha-2).
It is possible to specify region codes or postcodes that you want to filter or exclude.
destination: "FR,DE,CH,ES,IT",
# France without Corsica
destination: "FR-(2A,2B)",
# Corsica
destination: "FR(2A,2B)",
# World without Germany and Corsica
destination: "* - ( DE, FR(2A,2B) )",
Tip
In the editor, you can use countries codes but countries names and shortcuts to insert a group of countries too.
- UE or Union Européenne : adds the European Union countries.
- DOM : adds French Overseas Departments.
- COM : adds French Overseas Communities.
- Outre-Mer : adds the whole French Overseas.
- Corse : adds Corsica ("FR(2A,2B)").
You can interract with countries in the Preview. If you click on one of them, a menu gives you the possibility to perform some operations.
The code : `code`
This is the identifier of the shipping method.
It must be unique. If not unique, it will be changed.
The description : `description`
This will be the description given to the shipping method.
The usage is the same as the property label.
See the property destination.
The origin : `origin`
Same than destination but to filter shipping origin.
The syntax is the same as for destination filtering.
Customer groups : `customer_groups`
You can use the name or the ID of customer groups.
customer_groups: "NOT LOGGED IN,General",
# Groups NOT LOGGED IN and General by ID
customer_groups: "0,1",
# Group Retailer
customer_groups: "Retailer",