Vladimir

Vladimir

Был в сети 13 ноября 2023, 11:16
Заказы принимаю
Спасибо всем, обновился, сделал так
switch ($modx->event->name) {

    case 'msOnAddToCart':
        $res = $modx->getObject('modResource', 1);
        $defaultOptPrice = (int)$res->getTVValue('opt_price__default');
        
        $crt = $cart->get();

        $currentGoods = $modx->getObject('modResource', (int)$crt[$key]['id']);
        $currentGoodsOptPrice = (int)$currentGoods->getTVValue('opt_price');
        if(((int)$crt[$key]['price'] * (int)$crt[$key]['count']) >= $defaultOptPrice){
            
            $crt[$key]['old_price'] =  $crt[$key]['price'];
            $crt[$key]['price'] = $currentGoodsOptPrice;
            $crt[$key]['discount_price'] = $currentGoodsOptPrice;
            
            
        }

        $cart->set($crt);
        break;
 
}