Skip to content

Instantly share code, notes, and snippets.

@jerrydeakins
Created July 8, 2017 12:30
Show Gist options
  • Save jerrydeakins/af750b337308d07bf5d65504c94cf897 to your computer and use it in GitHub Desktop.
Save jerrydeakins/af750b337308d07bf5d65504c94cf897 to your computer and use it in GitHub Desktop.
Плагин смотрит TV с ценой в долларах, умножает на значение системной опции, округляет и записывает в TV с ценой в рублях
<?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