/** * Change rate of currency * * @param string $code * @param double $rate */ public function changeRate($code, $rate) { $primary = $this->getPrimaryCurrency(); if ($code == $primary) { return false; } $currency = $this->getById($code); if (!$currency) { return false; } $rate = (double) $rate; $old_rate = (double) $currency['rate']; if ($rate < 0) { return false; } if ($rate != $old_rate) { $result = $this->updateById($code, array('rate' => $rate)); $this->recalcProductPrimaryPrices($code); $this->recalcServicePrimaryPrices($code); $cache = new waRuntimeCache('shop_currencies'); $cache->delete(); if ($cache = wa('shop')->getCache()) { $cache->delete('currencies'); } return $result; } return true; }