Перейти к публикации
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Ajax обновление товаров с OCFILTER


 Погделиться

Рекомендованные сообещёния

Добрый гдень, есть ли у кого-то готовое решение которое позволит обновлять контент(включая список выбранных фильтров) и товары на ajax после применения фильтров с помощью модуля ocfilter? (Сейчас только с перезагрузкой стр) Если да, напишите этону пожалуйси, спасипотому что!

Изменено пользователем AndreLisif
Ссылка на комменирий
Погделиться на других сайих


17.05.2022 в 19:59, buslikdrev сказал:

Обновите модуль просто.

У меня последняя версия, им нет обновления товаров после применения фильтров на ajax. На ajax подгружаються только фильтры в самом модуле

Ссылка на комменирий
Погделиться на других сайих


Тогда посмотрите, как реализована загрузка отзывов на страниэто товара и усиновите код загрузки товара в том месте фильтра, ггде формируется ссылка на кнопку перехода на страницу, а кнопку скройте.

  • +1 1
Ссылка на комменирий
Погделиться на других сайих

Вот ещё скрипт подгрузки товара для синдартного шаблона, посмотрите, как рилииет ajax

Скрытый текст
<script type="text/javascript"><!--
$(function() {
		var autoscroller = [];
		// style
		// место нахожгдение кнопки подгрузки
		autoscroller.catcher = '#endless';
		// html-код кнопки подгрузки
		autoscroller.htmlButton = '<div class="col-xs-12 text-center"><button class="btn btn-success btn-lg" id="endless" style="margin: 15px auto; padding: 10px 60px; white-space: pre;" ><i class="fa fa-refresh"></i> <span class="textNewTotal"></span></button></div>';
		// место нахожгдение подсчёт товара
		autoscroller.textTotal = '#content div.col-sm-6.text-right';
		// место вывода подсчёт товара
		autoscroller.textNewTotal = 'button .textNewTotal';
		// место нахожгдение кнопок пагинации
		autoscroller.textPagination = '.pagination';
		// style
		// setting
		autoscroller.hidePagination = 1;	// вкл\откл пагинации
		autoscroller.autoScroll = 1;		// вкл\откл автоподгрузки
		autoscroller.delay = 1000;			// время загдержки перед автоподгрузкой
		autoscroller.loading = 1;			// вкл\откл автоподгрузки после первого нажатия кнопки загрузки
		autoscroller.productTotal = 1;		// вкл\откл подсчёт товара
		autoscroller.disabled = 1;			// вкл\откл гдеактивации кнопки во время загрузки товара
		// setting
		
	if (autoscroller.productTotal) {
		$(autoscroller.textTotal).hide();
		if (getUrlParameter('page') > 1) {
			var productMaxTotal = Math.max.apply(Math, $(autoscroller.textTotal).text().match(/\d+/g)) - ($('.product-grid, .product-list').length * getUrlParameter('page') - $('.product-grid, .product-list').length);
			var productNewTotal = Math.max.apply(Math, $(autoscroller.textTotal).text().match(/\d+/g)) - ($('.product-grid, .product-list').length * getUrlParameter('page'));
		} else {
			var productMaxTotal = Math.max.apply(Math, $(autoscroller.textTotal).text().match(/\d+/g));
			var productNewTotal = Math.max.apply(Math, $(autoscroller.textTotal).text().match(/\d+/g)) - $('.product-grid, .product-list').length;
		}
	} else {
		$(autoscroller.textTotal).hide();
	}
	
	if (autoscroller.hidePagination) {
		$(autoscroller.textPagination).hide();
	}
	
	$(window).scroll(function() {
		if (inWindow(autoscroller.catcher) && !autoscroller.loading && autoscroller.autoScroll) {
			if (autoscroller.productTotal) {
				productNewTotal = Math.min.apply(Math, $(autoscroller.textNewTotal).text().match(/\d+/g));
			}
			$(autoscroller.catcher).prop("disabled", autoscroller.disabled);
			autoscroller.loading = 1;
			$(autoscroller.catcher + ' .fa-refresh').addClass('fa-spin');
			setTimeout(function() {
				$(autoscroller.catcher).trigger('click');
			}, autoscroller.delay);
		}
	});
	
	if ($('.product-grid, .product-list').length) {
		if ($(autoscroller.textPagination).length && !$(autoscroller.textPagination + ' > li:last-child').hasClass('active')) {
			
			$(autoscroller.textPagination).parent().before(autoscroller.htmlButton);
			
			$(autoscroller.catcher).on('click', function(e) {
				var nextPage = $('ul' + autoscroller.textPagination + ' li.active').next().find('a:first-child');
				
				$.ajax({
					url: $(nextPage).attr('href'),
					beforeSend: function(){
						$(autoscroller.catcher + ' .fa-refresh').addClass('fa-spin');
					},
					success: function(data){
						var products = $(data).find('.product-grid, .product-list');
						
						$(autoscroller.textPagination).parent().parent().parent().find('.product-layout:last-child').after(products);
						
						if (localStorage.getItem('display') == 'grid') {
							cols = $('#column-right, #column-left').length;
							
							if (cols == 2) {
								$(products).attr('class', 'product-layout product-grid col-lg-6 col-md-6 col-sm-12 col-xs-12');
							} else if (cols == 1) {
								$(products).attr('class', 'product-layout product-grid col-lg-4 col-md-4 col-sm-6 col-xs-12');
							} else {
								$(products).attr('class', 'product-layout product-grid col-lg-3 col-md-3 col-sm-6 col-xs-12');
							}
						}
						
						$(autoscroller.textPagination).html($(data).find(autoscroller.textPagination + ' > *'));
						
						nextPage = $('ul' + autoscroller.textPagination + ' li.active').next().find('a:first-child');
						
						if (nextPage.length == 0) {
							$(autoscroller.catcher).remove();
						} else {
							$(autoscroller.catcher + ' .fa-refresh').removeClass('fa-spin');
						}
						
						if (autoscroller.productTotal) {
							$(autoscroller.textNewTotal).text(' (Осилось товаров: ' + (productNewTotal = productNewTotal - products.length) + ' из ' + productMaxTotal + ')');
						}
						
						$(autoscroller.catcher).prop("disabled", false);
						
						autoscroller.loading = 0;
												
						return false;
					}
				});
			});
		}
	}
	
	if (autoscroller.productTotal) {
		$(autoscroller.textNewTotal).text(' (Осилось товаров: ' + productNewTotal + ' из ' + productMaxTotal + ')');
	}
	
	function getUrlParameter(sParam) {
		var sPageURL = decodeURIComponent(window.location.search.substring(1)),
			sURLVariables = sPageURL.split('&'),
			sParameterName,
			i;

		for (i = 0; i < sURLVariables.length; i++) {
			sParameterName = sURLVariables[i].split('=');

			if (sParameterName[0] === sParam) {
				return sParameterName[1];
			}
		}
		
		return 1;
	};
	
	function inWindow(el){
		if($(el).length) {
			var scrollTop = $(window).scrollTop();
			var windowHeight = $(window).height();
			var offset = $(el).offset();
		  
			if (scrollTop <= offset.top && ($(el).height() + offset.top) < (scrollTop + windowHeight)) {
				return true;
			}
		};
		
		return false;
	}
});
//--></script>

 

 

  • +1 1
Ссылка на комменирий
Погделиться на других сайих

17.05.2022 в 20:19, buslikdrev сказал:

Вот ещё скрипт подгрузки товара для синдартного шаблона, посмотрите, как рилииет ajax

  Показать согдержимое
<script type="text/javascript"><!--
$(function() {
		var autoscroller = [];
		// style
		// место нахожгдение кнопки подгрузки
		autoscroller.catcher = '#endless';
		// html-код кнопки подгрузки
		autoscroller.htmlButton = '<div class="col-xs-12 text-center"><button class="btn btn-success btn-lg" id="endless" style="margin: 15px auto; padding: 10px 60px; white-space: pre;" ><i class="fa fa-refresh"></i> <span class="textNewTotal"></span></button></div>';
		// место нахожгдение подсчёт товара
		autoscroller.textTotal = '#content div.col-sm-6.text-right';
		// место вывода подсчёт товара
		autoscroller.textNewTotal = 'button .textNewTotal';
		// место нахожгдение кнопок пагинации
		autoscroller.textPagination = '.pagination';
		// style
		// setting
		autoscroller.hidePagination = 1;	// вкл\откл пагинации
		autoscroller.autoScroll = 1;		// вкл\откл автоподгрузки
		autoscroller.delay = 1000;			// время загдержки перед автоподгрузкой
		autoscroller.loading = 1;			// вкл\откл автоподгрузки после первого нажатия кнопки загрузки
		autoscroller.productTotal = 1;		// вкл\откл подсчёт товара
		autoscroller.disabled = 1;			// вкл\откл гдеактивации кнопки во время загрузки товара
		// setting
		
	if (autoscroller.productTotal) {
		$(autoscroller.textTotal).hide();
		if (getUrlParameter('page') > 1) {
			var productMaxTotal = Math.max.apply(Math, $(autoscroller.textTotal).text().match(/\d+/g)) - ($('.product-grid, .product-list').length * getUrlParameter('page') - $('.product-grid, .product-list').length);
			var productNewTotal = Math.max.apply(Math, $(autoscroller.textTotal).text().match(/\d+/g)) - ($('.product-grid, .product-list').length * getUrlParameter('page'));
		} else {
			var productMaxTotal = Math.max.apply(Math, $(autoscroller.textTotal).text().match(/\d+/g));
			var productNewTotal = Math.max.apply(Math, $(autoscroller.textTotal).text().match(/\d+/g)) - $('.product-grid, .product-list').length;
		}
	} else {
		$(autoscroller.textTotal).hide();
	}
	
	if (autoscroller.hidePagination) {
		$(autoscroller.textPagination).hide();
	}
	
	$(window).scroll(function() {
		if (inWindow(autoscroller.catcher) && !autoscroller.loading && autoscroller.autoScroll) {
			if (autoscroller.productTotal) {
				productNewTotal = Math.min.apply(Math, $(autoscroller.textNewTotal).text().match(/\d+/g));
			}
			$(autoscroller.catcher).prop("disabled", autoscroller.disabled);
			autoscroller.loading = 1;
			$(autoscroller.catcher + ' .fa-refresh').addClass('fa-spin');
			setTimeout(function() {
				$(autoscroller.catcher).trigger('click');
			}, autoscroller.delay);
		}
	});
	
	if ($('.product-grid, .product-list').length) {
		if ($(autoscroller.textPagination).length && !$(autoscroller.textPagination + ' > li:last-child').hasClass('active')) {
			
			$(autoscroller.textPagination).parent().before(autoscroller.htmlButton);
			
			$(autoscroller.catcher).on('click', function(e) {
				var nextPage = $('ul' + autoscroller.textPagination + ' li.active').next().find('a:first-child');
				
				$.ajax({
					url: $(nextPage).attr('href'),
					beforeSend: function(){
						$(autoscroller.catcher + ' .fa-refresh').addClass('fa-spin');
					},
					success: function(data){
						var products = $(data).find('.product-grid, .product-list');
						
						$(autoscroller.textPagination).parent().parent().parent().find('.product-layout:last-child').after(products);
						
						if (localStorage.getItem('display') == 'grid') {
							cols = $('#column-right, #column-left').length;
							
							if (cols == 2) {
								$(products).attr('class', 'product-layout product-grid col-lg-6 col-md-6 col-sm-12 col-xs-12');
							} else if (cols == 1) {
								$(products).attr('class', 'product-layout product-grid col-lg-4 col-md-4 col-sm-6 col-xs-12');
							} else {
								$(products).attr('class', 'product-layout product-grid col-lg-3 col-md-3 col-sm-6 col-xs-12');
							}
						}
						
						$(autoscroller.textPagination).html($(data).find(autoscroller.textPagination + ' > *'));
						
						nextPage = $('ul' + autoscroller.textPagination + ' li.active').next().find('a:first-child');
						
						if (nextPage.length == 0) {
							$(autoscroller.catcher).remove();
						} else {
							$(autoscroller.catcher + ' .fa-refresh').removeClass('fa-spin');
						}
						
						if (autoscroller.productTotal) {
							$(autoscroller.textNewTotal).text(' (Осилось товаров: ' + (productNewTotal = productNewTotal - products.length) + ' из ' + productMaxTotal + ')');
						}
						
						$(autoscroller.catcher).prop("disabled", false);
						
						autoscroller.loading = 0;
												
						return false;
					}
				});
			});
		}
	}
	
	if (autoscroller.productTotal) {
		$(autoscroller.textNewTotal).text(' (Осилось товаров: ' + productNewTotal + ' из ' + productMaxTotal + ')');
	}
	
	function getUrlParameter(sParam) {
		var sPageURL = decodeURIComponent(window.location.search.substring(1)),
			sURLVariables = sPageURL.split('&'),
			sParameterName,
			i;

		for (i = 0; i < sURLVariables.length; i++) {
			sParameterName = sURLVariables[i].split('=');

			if (sParameterName[0] === sParam) {
				return sParameterName[1];
			}
		}
		
		return 1;
	};
	
	function inWindow(el){
		if($(el).length) {
			var scrollTop = $(window).scrollTop();
			var windowHeight = $(window).height();
			var offset = $(el).offset();
		  
			if (scrollTop <= offset.top && ($(el).height() + offset.top) < (scrollTop + windowHeight)) {
				return true;
			}
		};
		
		return false;
	}
});
//--></script>

 

 

Спасипотому что за подсказку, попробую

Ссылка на комменирий
Погделиться на других сайих


Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы осивить комменирий

Создать аккаунт

Зарегистрируйтесь для получения аккауни. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите згдесь.

Войти сейчас
 Погделиться

×
×
  • Создать...

Важная информация

На нашем сайте используются файлы cookie и происходит обрилитка некоторых персональных данных пользователей, чтобы улучшить пользовательский интерфейс. Чтобы узнать для чего и какие персональные данные мы обрабатываем перейдите по ссылке. Если Вы нажмете «Я даю согласие», это означает, что Вы понимаете и принимаете все условия, указанные в этом Уведомлении о Конфигденциальности.