Post by fredJ » Thu Apr 11, 2024 4:41 pm

Version 3.0.2.0

A customer told me they find it annoying to have the page scroll up when the click "add to wishlist".
So I wanted to change that.
I tried changing /template/account/wishlist.twig to include "div style="position:fixed;" in the div, but it seems that file is cached somehow? I cleared all caching but nothing happens? Could it be vqmod?
How else can I change the behavior of what happens when I click "add to wishlist"? it triggers wishlist.add , where is that code located?

New member

Posts

Joined
Fri Jan 18, 2019 11:10 pm

Post by nonnedelectari » Thu Apr 11, 2024 6:57 pm

Javascript ajax calls in the associated view.

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by paulfeakins » Thu Apr 11, 2024 8:01 pm

fredJ wrote:
Thu Apr 11, 2024 4:41 pm
I cleared all caching but nothing happens?
https://www.antropy.co.uk/blog/how-to-c ... t-3-0-2-0/

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by fredJ » Thu Apr 11, 2024 9:15 pm

Thanks. I tried all the cache clearning but they didn't work.
But it gave me some ideas.

viewtopic.php?t=216444
Here it says how to remove the scroll effect.

Then I changed in stylesheet.css

to add this

.alert-dismissible {
position:fixed;
top: 0;
z-index: 500;
}

Then the alert box will be visible, at least.
Next step will be to make it fade out.

New member

Posts

Joined
Fri Jan 18, 2019 11:10 pm

Post by nonnedelectari » Thu Apr 11, 2024 9:24 pm

catalog/view/javascript/common.js

Code: Select all

var wishlist = {
	'add': function(product_id) {
		$.ajax({
			url: 'index.php?route=account/wishlist/add',
			type: 'post',
			data: 'product_id=' + product_id,
			dataType: 'json',
			success: function(json) {
				$('.alert-dismissible').remove();

				if (json['redirect']) {
					location = json['redirect'];
				}

				if (json['success']) {
					$('#content').parent().before('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
				}

				$('#wishlist-total span').html(json['total']);
				$('#wishlist-total').attr('title', json['total']);

				$('html, body').animate({ scrollTop: 0 }, 'slow');
			},
			error: function(xhr, ajaxOptions, thrownError) {
				alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
			}
		});
	},
	'remove': function() {

	}
}
this part sets the message and does the scrolling:

Code: Select all

				if (json['success']) {
					$('#content').parent().before('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div>');
				}

				$('#wishlist-total span').html(json['total']);
				$('#wishlist-total').attr('title', json['total']);

				$('html, body').animate({ scrollTop: 0 }, 'slow');
if you change that, clear your caches, including your browser cache as js is browser cached.

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm
Who is online

Users browsing this forum: No registered users and 38 guests