• Вопрос по JS как закрыть окно после добавление товара в корзину?

    skbeloff
    @skbeloff Автор вопроса
    Не силён в JS поэтому и спросил. Ну всё равно не срабатывает. Вот листинг.

    <script type="text/javascript"><!--
    $('select[name=\'recurring_id\'], input[name="quantity"]').change(function(){
    	$.ajax({
    		url: 'index.php?route=product/product/getRecurringDescription',
    		type: 'post',
    		data: $('input[name=\'product_id\'], input[name=\'quantity\'], select[name=\'recurring_id\']'),
    		dataType: 'json',
    		beforeSend: function() {
    			$('#recurring-description').html('');
    		},
    		success: function(json) {
    			$('.alert, .text-danger').remove();
    
    			if (json['success']) {
    				$('#recurring-description').html(json['success']);
    			}
    		}
    	});
    });
    //--></script>
    <script type="text/javascript"><!--
    $('#button-cart').on('click', function() {
    	$.ajax({
    		url: 'index.php?route=checkout/cart/add',
    		type: 'post',
    		data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
    		dataType: 'json',
    		beforeSend: function() {
    			$('#button-cart').button('loading');
    		},
    		complete: function() {
    			$('#button-cart').button('reset');
    		},
    		success: function(json) {
    			$('.alert, .text-danger').remove();
    			$('.form-group').removeClass('has-error');
    
    			if (json['error']) {
                    <?php if ($this->journal2->settings->get('quickview_product_options') !== '1'): ?>
                    top.location = '<?php echo str_replace('&amp;', '&', $this->url->link('product/product', 'product_id=' . $product_id)); ?>';
                    return;
                    <?php endif; ?>
    				if (json['error']['option']) {
    					for (i in json['error']['option']) {
    						var element = $('#input-option' + i.replace('_', '-'));
    
    						if (element.parent().hasClass('input-group')) {
    							element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
    						} else {
    							element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
    						}
    					}
    				}
    
    				if (json['error']['recurring']) {
    					$('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
    				}
    
    				// Highlight any found errors
    				$('.text-danger').parent().addClass('has-error');
    			}
    
    			if (json['success']) {
                    if (!parent.Journal.showNotification(json['success'], json['image'])) {
                        $('.breadcrumb').after('<div class="alert alert-success success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                    }
    
    				parent.$('#cart-total').html(json['total']);
    
    				$('html, body').animate({ scrollTop: 0 }, 'slow');
    
                    parent.$('#cart ul').load('index.php?route=common/cart/info ul li');
                    
    			}
    		}
    	});
    });
    Ответ написан