Перейти к содержимому


Вылазит Ошибка


  • Авторизуйтесь для ответа в теме
В теме одно сообщение

#1 ogonek7777

ogonek7777

    Активный участник

  • Пользователи
  • PipPipPipPip
  • 2 109 сообщений
  • ГородМосква

Отправлено 08 Октябрь 2016 - 13:06

при попытке удалить товар вылазит ошибка

Прикрепленные изображения

  • 2016-10-08_12-39-18.png


#2 Stasya

Stasya

    Активный участник

  • Модератоpы
  • 4 007 сообщений

Отправлено 10 Октябрь 2016 - 13:59

Просмотр сообщенияogonek7777 (08 Октябрь 2016 - 13:06) писал:

при попытке удалить товар вылазит ошибка

Вам необходимо в файле main.js найти блок
//ajax удаление товара из корзины
  function deleteCartItem (item_id) {
	$.ajax({
	  cache : false,
	  url : '/cart/delete/' + $('#' + item_id).data('mod-id') + '',
	  success: function(newData) {
		nd = $(newData);
	   
		//выведем сообщения об успешном обновлении корзины
		if (nd.find('.success').length) {
		  message = nd.find('.success').text();
		  message_type = 'success';
		}
		//или сообщение о том, что обновление не удалось
		else if (nd.find('.warning').length) {
		  message = nd.find('.warning').text();
		  message_type = 'error';
		}
		// Если есть функция, которая отображает сообщения пользователю
		if(typeof(noty) == "function") {
		  noty({
			text:message,
			layout:"center",
			type:message_type,
			textAlign:"center",
			easing:"swing",
			animateOpen:{"height":"toggle"},
			animateClose:{"opacity":"hide"},
			speed:"500",
			timeout:"2000",
			closable: false,
			modal: false,
			dismissQueue: true,
			onClose: true,
			killer: true});
		}
		//Удалим товарную позицию
		$('#' + item_id).remove();
			   
		if (nd.find('.item').length) {
		  // Сумма заказа
		  total_price = parseInt($('.cart-total-price .num').html().replace(/\s+/g, ''));
		  new_total_price = parseInt(nd.find('.cart-total-price .num').html().replace(/\s+/g, ''));
		  delta_sum = new_total_price - total_price;
	 
		  // Скидка
		  sale = $(".cart-price-general-sale").length ? parseInt($(".cart-price-general-sale .num").html().replace(/\s+/g, '')) : 0;
		  new_sale = nd.find(".cart-price-general-sale").length ? parseInt(nd.find(".cart-price-general-sale .num").html().replace(/\s+/g, '')) : 0;
		  delta_sale = new_sale - sale;
		 
		  //удалим поле скидки, если оно удалилось
		  newSale = nd.find('.cart-price-general-sale').length ? nd.find('.cart-price-general-sale') : 0;
		  if (!newSale.length && $('.cartForm .cart-price-general-sale').length) {
			$('.cartForm .cart-price-general-sale').parent().parent().remove();
		  }
		 
		  // Визуализируем подсчёт суммы скидки и итоговой суммы
		  var iter = 10; // число итераций смены цен
		  j = 1;
		  $(function priceAnim() {
			if (j > iter) return;
		   
			$('.cart-total-price .price .num').html(number_format(total_price + delta_sum*j/iter, 2, ',', ' '));
			//подправим значение общей стоимости, чтобы она была в изначальном формате
			if ( j == iter ) {
			  $('.cart-total-price .price').html(nd.find('.cart-total-price .price').html());
			}
			if ($(".cart-price-general-sale").length) {
			  $('.cart-price-general-sale .num').html(number_format(sale + delta_sale*j/iter, 2, ',', ' '));
			  if ( j == iter )
				$(".cart-price-general-sale").html(nd.find(".cart-price-general-sale").html());
			   
			  $('.cart-price-sale .num').html(number_format(sale + delta_sale*j/iter, 2, ',', ' '));
			  if ( j == iter )
				$(".cart-price-sale").html(nd.find(".cart-price-sale").html());
			}
					 
			j++;
			setTimeout(priceAnim, 40);
		  });
		}
		else {
		  $('.main_part_wrapper .cart-info').html(nd.find('.main_part_wrapper .cart-info').html());
		}
		$('#header .shopping_cart_block').html(nd.find('.shopping_cart_block').html());
	  },
	  error: function() {
		if(typeof(noty) == "function") {
		  noty({
			text: 'Проблемы с соединением. Повторите попытку позже.',
			layout:"center",
			type: 'error',
			textAlign:"center",
			easing:"swing",
			animateOpen:{"height":"toggle"},
			animateClose:{"opacity":"hide"},
			speed:"500",
			timeout:"2000",
			closable: false,
			modal: false,
			dismissQueue: true,
			onClose: true,
			killer: true});
		}
	  }
	});
  }
и замените его на
  //ajax удаление товара из корзины
  function deleteCartItem (item_id) {
	$.ajax({
	  cache : false,
	  url : '/cart/delete/' + $('#' + item_id).data('mod-id') + '',
	  success: function() {
		$.get("/cart", function(newData){
		nd = $(newData);
		//выведем сообщения об успешном обновлении корзины
		if (nd.find('.success').length) {
		  message = nd.find('.success').text();
		  message_type = 'success';
		}
		//или сообщение о том, что обновление не удалось
		else if (nd.find('.warning').length) {
		  message = nd.find('.warning').text();
		  message_type = 'error';
		}
		// Если есть функция, которая отображает сообщения пользователю
		if(typeof(noty) == "function") {
		  noty({
			text:message,
			layout:"center",
			type:message_type,
			textAlign:"center",
			easing:"swing",
			animateOpen:{"height":"toggle"},
			animateClose:{"opacity":"hide"},
			speed:"500",
			timeout:"2000",
			closable: false,
			modal: false,
			dismissQueue: true,
			onClose: true,
			killer: true});
		}
		//Удалим товарную позицию
		$('#' + item_id).remove();
			   
		if (nd.find('.item').length) {
		  // Сумма заказа
		  total_price = parseInt($('.cart-total-price .num').html().replace(/\s+/g, ''));
		  new_total_price = parseInt(nd.find('.cart-total-price .num').html().replace(/\s+/g, ''));
		  delta_sum = new_total_price - total_price;
	 
		  // Скидка
		  sale = $(".cart-price-general-sale").length ? parseInt($(".cart-price-general-sale .num").html().replace(/\s+/g, '')) : 0;
		  new_sale = nd.find(".cart-price-general-sale").length ? parseInt(nd.find(".cart-price-general-sale .num").html().replace(/\s+/g, '')) : 0;
		  delta_sale = new_sale - sale;
		 
		  //удалим поле скидки, если оно удалилось
		  newSale = nd.find('.cart-price-general-sale').length ? nd.find('.cart-price-general-sale') : 0;
		  if (!newSale.length && $('.cartForm .cart-price-general-sale').length) {
			$('.cartForm .cart-price-general-sale').parent().parent().remove();
		  }
		 
		  // Визуализируем подсчёт суммы скидки и итоговой суммы
		  var iter = 10; // число итераций смены цен
		  j = 1;
		  $(function priceAnim() {
			if (j > iter) return;
		   
			$('.cart-total-price .price .num').html(number_format(total_price + delta_sum*j/iter, 2, ',', ' '));
			//подправим значение общей стоимости, чтобы она была в изначальном формате
			if ( j == iter ) {
			  $('.cart-total-price .price').html(nd.find('.cart-total-price .price').html());
			}
			if ($(".cart-price-general-sale").length) {
			  $('.cart-price-general-sale .num').html(number_format(sale + delta_sale*j/iter, 2, ',', ' '));
			  if ( j == iter )
				$(".cart-price-general-sale").html(nd.find(".cart-price-general-sale").html());
			   
			  $('.cart-price-sale .num').html(number_format(sale + delta_sale*j/iter, 2, ',', ' '));
			  if ( j == iter )
				$(".cart-price-sale").html(nd.find(".cart-price-sale").html());
			}
					 
			j++;
			setTimeout(priceAnim, 40);
		  });
		}
		else {
		  $('.main_part_wrapper .cart-info').html(nd.find('.main_part_wrapper .cart-info').html());
		}
		$('#header .shopping_cart_block').html(nd.find('.shopping_cart_block').html());
	   
		});
	  },
	  error: function() {
		if(typeof(noty) == "function") {
		  noty({
			text: 'Проблемы с соединением. Повторите попытку позже.',
			layout:"center",
			type: 'error',
			textAlign:"center",
			easing:"swing",
			animateOpen:{"height":"toggle"},
			animateClose:{"opacity":"hide"},
			speed:"500",
			timeout:"2000",
			closable: false,
			modal: false,
			dismissQueue: true,
			onClose: true,
			killer: true});
		}
	  }
	 
	});
  }





Количество пользователей, читающих эту тему: 0

0 пользователей, 0 гостей, 0 анонимных