myshop-calculate:< expression >
Entity | Value |
---|---|
Attribute(s) | style |
Type | value |
Relation | productlist, moreinfo, orderprocess |
Sometimes it may be needed to show a calculated number in a template or orderprocess screen. The extension myshop-calculate can calculate and display a number for you. Need to format the number? Use myshop-calculate:format-number for this purpose.
Create option | format |
---|---|
format- number(number,format[,‘d ecimal-comma’]) | Required. Specifies the format pattern:
|
abs(number) | Returns the absolute value of the argument. Example: abs(3.14) Result: 3.14 Example: abs(-3.14) Result: 3.14 |
celling(number) | Returns the smallest integer that is greater than the number argument. Example: ceiling(3.14) Result: 4 |
floor(number) | Returns the largest integer that is not greater than the number argument. Example: floor(3.14) Result: 3 |
round(number) | Rounds the number argument to the nearest integer. Example: round(3.14) Result: 3 |
Example
This example shows how to calculate the number of points granted for a basket row. In this example the column called ‘product_points’ is added as backoffice/xml field, as such it is available using the extra-[columnname] expression. The calculation calculates the number of points by using this column and multiply it with the quantity of the current basket row.
<tr class="myshp_basket_product" style="myshop-repeat:basket;">
<td class="myshp_basket_product_name">
<span style="myshop-value:product-id"></span>
</td>
<td class="myshp_basket_product_description">
<span style=”myshop-value:description;" ></span>
</td>
<td class="myshp_basket_product_quantity">
<span style="myshop-value:quantity;"></span>
(points <span style="myshop-calculate:{extra-product_points}*{ quantity };"></span>)
</td>
</tr>
See also
The following extensions may also be interesting if you plan to use this extension:
Post your comment on this topic.