A
A
Antiless2016-06-08 23:58:39
PHP
Antiless, 2016-06-08 23:58:39

How to correct string in foreach variable and divide it by number?

There will be a denomination in Belarus soon and many customers ask to add another price, next to the main one. Due to some circumstances, there is no access to the source codes, there is only a template file, where the actual price is displayed. Bypassing the array of goods, we have the variable $module_data , we need to take the price from it ( $module_data.PRODUCTS_PRICE comes out ), remove the points and divide by 10000 - I tried 3 different ways, but nothing happened:

{($module_data.PRODUCTS_PRICE|replace:'.':'') / 10000}

{php} echo intVal(str_replace(".", "", $this->get_template_vars('module_data.PRODUCTS_PRICE'))) / 10000; {/php}

{math equation="x / y" x=$module_data.PRODUCTS_PRICE|replace:'.':'' y=10000}

I myself am not special in smart, I will be glad if you tell me what needs to be done so that at least one of the options will work

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
neeil, 2016-06-09
@neeil

you need to make an array in the controller, place a variable with the price there and call and divide this array inside the cycle

A
Andrew, 2016-08-25
@iCoderXXI

In principle, smarti allows you to perform many PHP functions directly (depending on the version), for example, you can try this code {floor(floor($module_data.PRODUCTS_PRICE*100)/10000)}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question