price-calc Configuration

Without any doubt, the plugin’s configuration screens are difficult to use and understand. The author is working on a more intuitive graphical user interface. We would appreciate any suggestion.

Go to the official plugin homepage to support this project and get more information.


Configuration Principles

The general idea is that the administrator first defines a “structure” for his products. The structure is made up of several elements that define both, the price structure and the front-end form
that is displayed to the end user. The actual values (prices) that will be used for the calculation are defined separately on the “Prices” screen. By default, all resulting values are sum up to the total price. However, you can also define a custom formula.


Structure settings

The structure settings can be found on the “Structure” screen
in the “Structure” section. There each item/characteristics of the
product is described.


Heading

Headings are used to

Syntax:

==<title>|<classes>
title The text to be displayed in the heading
classes The classes to be assigned to the corresponding HTML
element. This is used for CSS styling.


Fixed value

Fixed values have no visible in the front-end form. They are used for calculation only. The corresponding values are set in the “prices” section.

Syntax:

#<id>|<title>
id unique identifier for internal use only.
title The value’s title

Example:

#base_price|Base price

Note that the title is only used on the “Prices” screen.

Option list

This element generates a pull-down menu in the front-end. The end-user can choose among several options. Each of these options has a price value that can be set in the “Prices” section and the price of the selected option will be applied.

Syntax:

@<id>|<title><required>|<columns>|<condition>|<modifiers>
-<id1>|<title1>
-<id2>|<title2>
-<id3>|<title3>
...
id unique identifier for internal use only
title The element’s title
required Append an asterik (’*') if this is an obligatory value or leave blank.
columns (Optional) number of columns to be used in the price grid that appears on the “Prices” screen
condition (Optional) Here you can set a condition for the element to be displayed. The element will only show up in the form if the condition is met. Right now the condition can only have the following syntax:

<id> in (<value1>, <value2>,...)

This checks whether the element with the unique identifier <id> has one of the values specified in the comma seperated list enclosed by brackets.

modifiers (Optional) This field can currently only hold the following syntax:

default=<value>

This sets the default value of the text input box to the given value

id1 An option’s internal unique identifier for internal use only
title1 An option’s title. It will be displayed as one row in the pull-down menu

Example:

@orig_lang|Original Language*|1||default=es
-0|From...
-en|English
-es|Spanish
-de|German
-fr|French

This example code is used by a translation company. The user can choose among a set of languages, each of them might correspond to a different price.

Free number entry

This element generates a text input box in the front-end where the end-user can type in any number. For the calculation this number will be multiplied with the unit price set in the “Prices” screen.

Syntax:

$<id>|<title><required>|<modifiers>
id unique identifier for internal use only
title The element’s title
required Append an asterik (’*') if this is an obligatory value or leave blank.
modifiers (Optional) This field can currently only hold the following syntax:

default=<value>

This sets the default value of the text input box to the given value.

Example:

$tshirt|Number of T-Shirts|default=10


Value display

This element does not correspond to an input element. Instead, it displays in the front-end values that are generated as partial results in the calculation formula. See chapter 3.1 on how to define variables for partial results.

Syntax:

?<id>|<variable>|<title>
id unique identifier for internal use only
variable the name of the variable (defined in the formula)
title The element’s title

The result is displayed as the content of an HTML <span> tag.


Formula

The operations to be executed for the calculation are defined in the “Formula” section on the “Structure” screen. If you merely need to sum up all prices to a total result you can simply leave the formula blank. Otherwise you will have to specify how the result shall be calculated. Rather than using a usual mathematical formula syntax, the formula is expressed as a script with each line rerpresenting one mathematical operation with the following syntax:

<operator><operand>

You can think of this format as the input of an old-school desktop calculating machine where each operation is typed in line by line.
The <operator> can be: +,* or %, indicating the
corresponding mathematical operation. Here the <operand> is the <id> on an element whose price value will be applied.

Example:
+orig_language
+dest_language
*words
+base_price
%student
+download

For your understanding the resulting calculation would be, mathematically spoken:

total = (orig_lang+dest_lang)*words * (100+student)/100 + download

 

Partial results

Use an equation sign (=) as an operator to store partial result in a variable. Such a variable can be displayed to the user in a Value Display element, as described in chapter 2.4.

Example:

+orig_language
+dest_language
*words
+base_price
=price
%student
+download

Here a partial result is stored in a variable called “price”.

price = (orig_lang+dest_lang)*words
total = price*(100+student)/100 + download

This page is wiki editable click here to edit this page.