Created
July 8, 2017 12:30
-
-
Save jerrydeakins/af750b337308d07bf5d65504c94cf897 to your computer and use it in GitHub Desktop.
Плагин смотрит TV с ценой в долларах, умножает на значение системной опции, округляет и записывает в TV с ценой в рублях
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$priceusd = $modx->getObject('modTemplateVar', array('name'=>'priceUSD')); | |
if (!$priceusd) { //проверки, получен ли объект. | |
return; | |
} | |
$priceusd = $priceusd->getValue($id); | |
if ($priceusd > 0) { | |
$usd = $modx->getOption('usd_course'); | |
$val = $priceusd * $usd; | |
$val = round($val, -2); | |
$tv = $modx->getObject('modTemplateVar', array('name'=>'price')); | |
$tv->setValue($resource->get('id'), $val); | |
$tv->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment