Advertisement
Sadchenko

Ubercart 2 - "Плюс", "Минус" к полю коллличества товара.

Sep 19th, 2016
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php //в файле ubercart\uc_product\uc_product.module, строка 1478
  2.   if ($node->default_qty > 0 && variable_get('uc_product_add_to_cart_qty', FALSE)) {
  3.     $form['qty'] = array(
  4.       '#type' => 'uc_quantity',
  5.       '#title' => t('Quantity'),
  6.       '#default_value' => $node->default_qty,
  7. +     '#prefix' => '<span class="minus">-</span>',
  8. +     '#suffix' => '<span class="plus">+</span>',
  9.     );
  10.   }
  11. ?>
  12.  
  13. <?php //В подвал page.tpl.php
  14.     $is_node = (arg(0) == 'node' && is_numeric(arg(1))) ? TRUE : FALSE;
  15.     if(!$is_front && !$is_node) {
  16. ?>
  17. <script>
  18.         $(document).ready(function() {
  19.             $('.minus').click(function () {
  20.                 var $input = $(this).parent().find('input.form-text');
  21.                 var count = parseInt($input.val()) - 1;
  22.                 count = count < 1 ? 1 : count;
  23.                 $input.val(count);
  24.                 $input.change();
  25.                 return false;
  26.             });
  27.             $('.plus').click(function () {
  28.                 var $input = $(this).parent().find('input.form-text');
  29.                 $input.val(parseInt($input.val()) + 1);
  30.                 $input.change();
  31.                 return false;
  32.             });
  33.         });
  34. </script>
  35. <? } ?>
  36.  
  37. <script>
  38. //В  node-product.tpl.php (страница ноды), а так же в блока views-view-unformatted...(при наличии)
  39.         $(document).ready(function() {
  40.             $('.minus').click(function () {
  41.                 var $input = $(this).parent().find('input.form-text');
  42.                 var count = parseInt($input.val()) - 1;
  43.                 count = count < 1 ? 1 : count;
  44.                 $input.val(count);
  45.                 $input.change();
  46.                 return false;
  47.             });
  48.             $('.plus').click(function () {
  49.                 var $input = $(this).parent().find('input.form-text');
  50.                 $input.val(parseInt($input.val()) + 1);
  51.                 $input.change();
  52.                 return false;
  53.             });
  54.         });
  55. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement