Сниппет вывода текущих скидок модуля Total Discount

<?php

  1. if (module_exists('uc_discount_total')) { 
  2. $rates_res = db_query('SELECT * FROM {uc_discount_total}');
  3. if ($rates_res->num_rows != NULL) {
  4. print t('Currently we have the following discount rates enabled');
  5. print '<table class="discount-rates">
  6. <tr>
  7. <th>'.t('Total amount range').'</th>
  8. <th>'.t('Your discount').'</th>
  9. </tr>';
  10. while($row = db_fetch_array($rates_res)) {
  11. print '<tr>
  12. <td>'.round($row['total_min']).' &#8212; '.round($row['total_max']).'</td>
  13. <td>'.round($row['total_rate']).'</td>
  14. </tr>';
  15. }
  16. print '</table>';
  17. }
  18. }
  19.  
  20. ?>

Версия с theme table

  1. if (module_exists('uc_discount_total')) {
  2. $rates_res = db_query('SELECT * FROM {uc_discount_total}');
  3. if ($rates_res->num_rows != NULL) {
  4. $header = array(t('Total amount range'), t('Your discount'));
  5. while($row = db_fetch_array($rates_res)) {
  6. 	$rows[] = array(round($row['total_min']) . ' &#8212; ' . round($row['total_max']), round($row['total_rate']));
  7. }
  8. print theme('table', $header, $rows, array('class' => 'discount-rates'), t('Currently we have the following discount rates enabled'));
  9. }
  10. }

Теги: