Skip to content

Instantly share code, notes, and snippets.

@webinmd
Forked from Burick/ms_modifiPrice.php
Created February 3, 2019 11:53
Show Gist options
  • Save webinmd/0ad7af1c764e592a55e065b806e26c23 to your computer and use it in GitHub Desktop.
Save webinmd/0ad7af1c764e592a55e065b806e26c23 to your computer and use it in GitHub Desktop.
пересчет цены для минишопа в зависимости от курса из системной настройки current_rate
<?php
/*
пересчет цены в зависимости откурса
из системной настройки current_rate
плагин на событие минишопа msOnGetProductPrice
*/
switch ($modx->event->name) {
case 'msOnGetProductPrice':
$values = & $modx->event->returnedValues;
// Цена может меняться несколькими плагинами сразу, поэтому проверяем:
if (isset($values['price'])) {
$price = $values['price'];
}
// пересчитываем цену
if( !$current_rate = $modx->getOption('current_rate') ){
$current_rate = 1;
}
$values['price'] = $price * $current_rate;
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment