Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////Функция в template.php
- function ubercart_popup() {
- if (module_exists('uc_cart')) {
- $items = uc_cart_get_contents();
- if (empty($items)) {
- return theme('uc_empty_cart');
- }
- $output = '';
- foreach (uc_cart_cart_pane_list($items) as $pane) {
- if ($pane['enabled']) {
- $output .= $pane['body'];
- }
- }
- return '<div id = "uc_popup">'. $output .'</div>';
- }
- }
- //Вывод в блоке
- print ubercart_popup();
- //Функция для склонения товаров
- function numberProduct($number, $titles) {
- $cases = array (2, 0, 1, 1, 1, 2);
- return $titles[ ($number%100>4 && $number%100<20)? 2 : $cases[min($number%10, 5)] ];
- }
- //Применение
- $a = count(uc_cart_get_contents());
- echo $a.' товар'.numberProduct($a, array('','а','ов'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement