It is possible to invoke Interface tags also by using programming languages, such as PHP or JavaScript (however, it is not possible to use server-side programming languages ​​in MyCashflow).

By using tags with programming languages, you can, for example, retrieve content from our dictionary tool by using AJAX calls, or print a product list from your online store on another web page.

If you plan on integrating your online store with any external software, use the MyCashflow REST API to process and retrieve the contents of the online store.

Syntax

Each Interface tag has its own access point in the online store with the address in the following format:

https://online-store-name.mycashflow.fi/interface/TagName?attribute=value

If the invoked tag has attributes, they can be given values ​​by adding them to the address of the tag's access point as GET parameters, as shown above.

Scope in tags' access points

Using certain tags requires that a content type, such as product, is set in their scope in their usage environment. These include, for example, tags that print product data, such as {ProductName}, which only work in an environment that has a selected or otherwise defined scope of a product.

When tags are invoked in programming languages, the scope must be set by using the set parameters:

ParameterCorresponds to the address
setProduct=id/product/id/...
setCategory =id/category/id/...
setBrand=id/brand/id/...
setPage=id/page/id/...
setNewsItem=id/news/id/...

Currently, product bundles have no dedicated access point in the Interface system.

set parameters are set in the same way as the GET parameter as other attributes given to the tag:

http://online-store-name.mycashflow.fi/interface/ProductName?setProduct=24

In the example, the tag call would print the same content as the {ProductName} used on the product page with ID no. 24.

Attributes

Many attributes of Interface tags can be used when tags are invoked in programming languages.

The following sections present the syntax of different types of attributes at Interface tags' access points.

Kuva 1. Text, numbers and booleans

For example, string values are used to retrieve words from the dictionary:

https://online-store-name.mycashflow.fi/interface/Text?code=AboutUs

Numeric values are given, for example, when determining the ID of the content to be retrieved:

https://online-store-name.mycashflow.fi/interface/Category?id=4&helper=helpers/helper-file

Some attributes are assigned a boolean value (true / false):

https://online-store-name.mycashflow.fi/interface/ProductName?setProduct=4&escape=true
Kuva 2. Lists

In case of tags that have attributes in form of a list, their syntax is similar when using tags in templates and through the access point.

https://online-store-name.mycashflow.fi/interface/Products?id=1|4|45
Kuva 3. File references

Some tags have attributes that are given a file reference as their value. An example of such a tag is the {Helper} tag that was used below:

https://online-store-name.mycashflow.fi/interface/Helper?file=helpers/helper-file

The file reference is assigned in relation to the root directory of the theme in use.

If the file to be retrieved uses e.g. product tags, you must set the desired product with the setProduct parameter. Read more about the set parameters.

JavaScript/jQuery (AJAX requests)

With JavaScript it is possible to perform asynchronous calls to Interface tags. In this way, you can, for example, retrieve contents from the dictionary without reloading the page.

$.get('http://demo.mycashflow.fi/interface/Text?code=TargetContent',
    function(data) {
        $('.result').html(data);
    }
);

Note that tags' attributes are indicated as GET parameters in the address of the called tag. In the example, the {Text} tag is used to retrieve content from the dictionary. The code of the word to be retrieved is added to the tag as the value of the code attribute.

The request is sent by using the jQuery get() method. The HTML content retrieved by the request can then be written to the desired HTML element.

PHP

The server-side programming language PHP also makes it possible to retrieve content from MyCashflow store.

To call tags, you can use, for example, the PHP file_get_contents() function:

$new_products = file_get_contents("http://demo.mycashflow.fi/interface/NewProducts?limit=6");
echo $new_products;

In the example, the store's 6 newest products are retrieved by using the {NewProducts} tag.

As the tags return a HTML-formatted content, the content of the $new_products variable can be printed on the page as it is.

Limitations and known issues

Tags that can be retrieved from the /interface address have the following limitations and known issues:

  • Order tags are no available
  • The functioning of some tags is based on a visitor-specific session. If the tags are called with a server-side programming language (for example PHP), the visitor-specific session must be transmitted separately or tags won't work correctly. This restriction does not apply to the store's internal AJAX invitations.

    Examples of session-based tags are customer data and shopping cart tags.

  • If the content printed by the tag will be displayed under another domain, add a domain name to the beginning of the links' and images' path, e.g. href="http://www.mcf-kauppa.fi/product/3"