Documentation of Advanced Shipping extension for Magento 2 by Owebia

Introduction

Advanced Shipping is an extension for the e-commerce solution Magento.

The syntax using PHP 5.6 allows a great flexibility in setting delivery charges.

Technical Informations

The usage of the PHP syntax (with an Abstract Syntax Tree) has been preferred to the usage of a JSON syntax (with regular expressions and the eval function) as in previous versions of the extension. This is the result of considerations on security and performance.

The PHP code defined in the configuration is not evaluated with the eval function for security reasons. The library PHP-Parser is used to obtain an Abstract Syntax Tree (AST). The AST is browsed and only a limited set of functions and variables is allowed.

As the AST is not version-dependent, you can use the PHP 5.6 syntax even if your server uses a lower version of PHP.

Use Variables and Functions

1. Variables

There are global variables and local variables that you can access with array functions and callbacks.

If you activate the debug option, you can see all data available for each object that you use.
Remember that you don't have access to all methods of the original objects because they are not accessed directly.

1.1. Global variables

These variables are global variables and can be accessed everywhere (use the global keyword when you are inside a function).

The request object (\Magento\Quote\Model\Quote\Address\RateRequest) given by Magento: