Post by Mathewbuer » Fri Aug 22, 2014 9:54 pm

is it possible to refresh the page after someone has added the product to the cart ?

ive got a mod which dose some validation for custom size, once the item has been added to the cart the only way for the validation to work again is to refresh the page.

Active Member

Posts

Joined
Mon Feb 07, 2011 8:24 am

Post by Mathewbuer » Fri Aug 22, 2014 10:57 pm

ive just tried adding the following to this function under common,js

ORIGINAL

Code: Select all

function addToCart(product_id, quantity) {
	quantity = typeof(quantity) != 'undefined' ? quantity : 1;

	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: 'product_id=' + product_id + '&quantity=' + quantity,
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, .information, .error').remove();
			
			if (json['redirect']) {
				location = json['redirect'];
			}
			
			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');

			}	
		}
	});
}
MODIFIED REDIRECT AFTER SUCCESSFUL ADD TO CART

Code: Select all

function addToCart(product_id, quantity) {
	quantity = typeof(quantity) != 'undefined' ? quantity : 1;

	$.ajax({
		url: 'index.php?route=checkout/cart/add',
		type: 'post',
		data: 'product_id=' + product_id + '&quantity=' + quantity,
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, .information, .error').remove();
			
			if (json['redirect']) {
				location = json['redirect'];
			}
			
			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'); 
				location.reload(); 

			}	
		}
	});
}

Active Member

Posts

Joined
Mon Feb 07, 2011 8:24 am
Who is online

Users browsing this forum: No registered users and 116 guests