Skip to content

Instantly share code, notes, and snippets.

@vgrish
Created December 10, 2016 07:20
Show Gist options
  • Save vgrish/5e77f10d5b92ff069dbfbaf944d4944f to your computer and use it in GitHub Desktop.
Save vgrish/5e77f10d5b92ff069dbfbaf944d4944f to your computer and use it in GitHub Desktop.
<?php
/** @var $cost */
/** @var $options */
/** @var $modifications array */
switch ($modx->event->name) {
case 'msopOnGetFullCost':
if (!$msoptionsprice = $modx->getService('msoptionsprice')
) {
return false;
}
$tkan = isset($options['tkan']) ? $options['tkan'] : 0;
if (!$tkan) {
return;
}
/** @var msProduct $product */
if (!$tkan = $modx->getObject('msProduct', (int)$tkan)) {
return;
}
$optPrice = $tkan->get('price');
if (!$optPrice) {
return;
}
$cost = $cost + $optPrice;
$cost = $msoptionsprice->formatPrice($cost, true, true);
$values = $modx->Event->returnedValues;
$values['cost'] = $cost;
$modx->event->returnedValues = $values;
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment