ibexa

Path

ez publish / technical manual / 4.3 / features / multi-currency / multi-price products


Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.

Multi-price products

An actual product is represented by a content object (with at least one node assignment) that contains information about the product itself along with a price. The price can be represented by an attribute that makes use of the built-in price or multi-price datatype. These are special datatypes which plug more deeply into the system and connect content objects with the webshop system. The main difference is that the price datatype allows to specify only one price value for each object (simple price product) whereas the multi-price datatype makes it possible to specify several price values in different currencies for each object (multi-price product). Please note that simple price products are incompatible with multi-currency feature.

A content class can only contain one price attribute or one multi-price attribute. There is no way to have a simple price product and a multi-price one in the shopping basket at the same time and it is not recommended to use both price and multi-price datatype on your site.

If you are going to use multi-price products, you should create at least one content class containing an attribute of the multi-price datatype as described in the next subsections. Instances/objects of this class will be treated as multi-price products. If you already have simple price products, you can automatically convert these to multi-price products as described in the "Upgrading your webshop" section.

Creating a product class

Access the "Setup" tab in the administration interface, click "Classes" on the left, select the "Content" class group and click the "New class" button located in the bottom of the list. You will be taken to the class edit interface as shown in the screenshot below.

The class edit interface for a product class.

The class edit interface for a product class.


Specify name, identifier, object name pattern and container flag for the newly created class and add the desired attributes using the drop-down list located in the bottom of the class edit interface.

Multi-price attribute

To add an attribute of the multi-price datatype, select the desired datatype from this list, click the "Add attribute" button and edit the newly added attribute (see the screenshot below).

Class attribute edit interface for the "Multi-price" datatype.

Class attribute edit interface for the "Multi-price" datatype.


It is recommended to specify "price" as the identifier (this value is used in the additional view templates). You have to select one of the predefined currencies as "default currency". This currency will be used for custom prices by default.

Example

Let's say that there are four predefined currencies: NOK, EUR, USD, UAH, and you are creating a class called "Products" with a multi-price attribute. If you set EUR as "default currency", the system will create a base price in EUR and auto prices in NOK, USD, UAH for each new object of this class. When a new product is created, the system will set this base price to 0.00 but you can specify the desired value instead (for example € 50). It is also possible to remove this price and create a new base price in some other currency (for example $60).

After adding the attributes, click "OK" to save the class.

Please note that if you need several different structures for storing info about your products, you can create several multi-product classes. If you sell for example computer hardware, you may need several content classes called "Monitors", "Printers", "Scanners" and so on. In this case, you will be able to filter products by class name in the products overview interface.

Creating a product

If you have a content class with multi-price datatype, you can create objects of this class i.e. your multi-price products. Please refer to the "Adding content" chapter of the "User manual" for more information about adding content objects.

Templates for viewing multi-price products

By default, the system will display prices in all currencies to a user. This is determined by the default "ezmultiprice.tpl" template located in the "templates/content/datatype/view/" directory of the standard design.

If you wish to display only price in the preferred currency, you can use the "multiprice.tpl" template located in the "override/templates/datatype/" directory of the base design. To do this, add the following lines to the "override.ini.append.php" file located in the "settings/siteaccess/example" directory where "example" is the name of your siteaccess (actual site but not the administration interface):

[multiprice]
Source=content/datatype/view/ezmultiprice.tpl
MatchFile=datatype/multiprice.tpl
Subdir=templates

It is also recommended to add a possibility for site visitors to change their preferred currency "on-the-fly" as described in the "Adding a toolbar for customers" section.

The following templates for viewing multi-price products are also available:

  • design/base/override/templates/full/multiprice_product.tpl
  • design/base/override/templates/line/multiprice_product.tpl
  • design/base/override/templates/embed/multiprice_product.tpl
  • design/base/override/templates/listitem/multiprice_product.tpl

To use these templates, add the following lines to the "override.ini.append.php" file:

[multiprice_product_full]
Source=node/view/full.tpl
MatchFile=full/multiprice_product.tpl
Subdir=templates
Match[class_identifier]=myproduct
 
[multiprice_product_line]
Source=node/view/line.tpl
MatchFile=line/multiprice_product.tpl
Subdir=templates
Match[class_identifier]=myproduct
 
[multiprice_product_embed]
Source=content/view/embed.tpl
MatchFile=embed/multiprice_product.tpl
Subdir=templates
Match[class_identifier]=myproduct
 
[multiprice_product_listitem]
Source=node/view/listitem.tpl
MatchFile=listitem/multiprice_product.tpl
Subdir=templates
Match[class_identifier]=myproduct

and replace "myproduct" with the actual class identifier of your multi-price products. (To check the class identifier, access the "Setup" tab in the administration interface, click "Classes" on the left, select the "Content" class group and find your multi-price product class.)

If you are going to use these templates, you will have to specify "user_preferred_currency" in the "CachedViewPreferences[full]" setting for all siteaccesses. To do this, open the "site.ini.append.php" configuration file located in the "settings/siteaccess/example" directory (replace "example" with the actual name of the siteaccess) and edit it. If the "[ContentSettings]" section of the configuration file already contains something like

CachedViewPreferences[full]=<list_of_user_preferences>

then you will have to append a semicolon and "user_preferred_currency" at the end of the line, for example:

CachedViewPreferences[full]=admin_navigation_content=0;
admin_navigation_details=0;<...>;admin_bookmarkmenu=1;
admin_left_menu_width=13;user_preferred_currency=''

Note that this configuration line tends to be very long. It is simplified in the example above (a lot of settings were replaced with <...> in order to keep things short).

If the "[ContentSettings]" section does not contain a line that starts from "CachedViewPreferences[full]", create it:

CachedViewPreferences[full]=user_preferred_currency=''

If this setting is not specified, your customers will have problems when changing the preferred currency setting (the interface will not be updated because of the cache problem).

Svitlana Shatokhina (05/05/2006 1:22 pm)

Geir Arne Waaler (13/09/2010 2:12 pm)

Svitlana Shatokhina, Geir Arne Waaler


Comments

There are no comments.