Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Дублирование кнопки купить


 Share

Recommended Posts

Хочу сделать в карточке товара дублирование кнопки купить например внизу после описания.

Но когда дублирую этот код, первая кнопка работает, а вторая не реагирует на нажатие. Мож кто подскажет как правильно дублировать кнопку купить? Спасибо!

<div class="cart">
        <div><?php echo $text_qty; ?>
          <input type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />
          <input type="hidden" name="product_id" size="2" value="<?php echo $product_id; ?>" />
           
        <input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" />   
        </div>
        <?php if ($minimum > 1) { ?>
        <div class="minimum"><?php echo $text_minimum; ?></div>
        <?php } ?>
      </div>

 

и когда просто выносишь код кнопки из блока в другое место <input type="button" value="<?php echo $button_cart; ?>" id="button-cart" class="button" /> 

тоже перестает работать!

Link to comment
Share on other sites


  • 1 month later...

Хочу рядом с основной кнопкой поместить такую же, с надписью "Купить в кредит" просто для информации что возможна продажа в кредит. Какой-то особый функционал при этом не требуется так как кредит оформляется через отдельный интерфейс, поэтому достаточно чтоб товар просто попал в корзину.

Link to comment
Share on other sites


Вторую кнопку сделайте вот так:

<input type="button" value="Купить в кредит" id="button-cart2" class="button" />

А внизу страницы вставьте

 

<script type="text/javascript"><!--$('#button-cart2').bind('click', function() {	$.ajax({		url: 'index.php?route=checkout/cart/add',		type: 'post',		data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),		dataType: 'json',		success: function(json) {			$('.success, .warning, .attention, information, .error').remove();						if (json['error']) {				if (json['error']['option']) {					for (i in json['error']['option']) {						$('#option-' + i).after('<span class="error">' + json['error']['option'][i] + '</span>');					}				}			} 						if (json['success']) {				$('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');									$('.success').fadeIn('slow');									$('#cart-total').html(json['total']);								$('html, body').animate({ scrollTop: 0 }, 'slow'); 			}			}	});});//--></script>

Как видите - это просто копия скрипта, который обрабатывал клик по кнопке заказа. В нём изменился только id этой кнопки, чтобы он реагировал на нашу новую, которую мы создали

Link to comment
Share on other sites

Попробовал, но кнопка на нажатия не реагирует.

Пробовал такой записью сделать кнопку как в примере <input type="button" value="Купить в кредит" id="button-cart2" class="button" />

Но все же мне хочется выдержать единый стиль, поэтому сделал кнопку по аналогии с существующей <a id="button-cart2" class="button"><span><?php echo "Купить в кредит"; ?></span></a><br>

Но и в том и в другом случае при нажатии ничего не происходит.

Link to comment
Share on other sites


 <a id="button-cart2" class="button"><span><?php echo "Купить в кредит"; ?></span></a><br>

Откуда у вас взялся такой код? У меня на странице товара кнопка задаётся именно тем способом, который я выше привёл.

Link to comment
Share on other sites

Все разобрался. У меня немножко другой скрипт используется от модуля быстрого оформления. Все работает! Большое спасибо!

Link to comment
Share on other sites


  • 2 months later...

а в каком файле это надо дописать? надо чтоб эта кнопка была в категориях, карточке товара, корзине

Это минимум три разных файла: product.tpl, category.tpl и шаблон корзины (может отличаться в зависимости от установленных дополнений)

Link to comment
Share on other sites

  • 10 months later...

Может кто сталкивался, кнопка "купить" в сетке товаров привязана к кнопке "купить" в карточке товара, т.е. если меняю размер или текст кнопки в карточке то она автоматом меняется и в сетке, а хотелось бы обозвать их по разному и задать разный размер, как сделать отвязку?  :ugeek:

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.