/** * Implements hook_commerce_currency_info_alter(). */ function commerce_rub_commerce_currency_info_alter(&$currencies, $langcode) { // Запрещаем оперировать копейками $currencies['RUB']['rounding_step'] = 1; // Удаляем копейки из вывода $currencies['RUB']['format_callback'] = 'commerce_rub_rub_currency_format'; } /** * Currency format callback. */ function commerce_rub_rub_currency_format($amount, $currency, $object) { $round_amount = commerce_currency_round(abs($amount), $currency); $price = number_format($round_amount, 0, $currency['decimal_separator'], $currency['thousands_separator']); $replacements = array( '@code_before' => $currency['code_placement'] == 'before' ? $currency['code'] : '', '@symbol_before' => $currency['symbol_placement'] == 'before' ? 'rub' : '', '@price' => $price, '@symbol_after' => $currency['symbol_placement'] == 'after' ? 'rub' : '', '@code_after' => $currency['code_placement'] == 'after' ? $currency['code'] : '', '@negative' => $amount < 0 ? '-' : '', '@symbol_spacer' => $currency['symbol_spacer'], '@code_spacer' => $currency['code_spacer'], ); return trim(t('@code_before@code_spacer@negative@symbol_before@price@symbol_spacer@symbol_after@code_spacer@code_after', $replacements)); }