Jump to content
Guisp

autorefresh_notifications is not defined - Cannot navigate the BackOffice

Recommended Posts

I've got this error, when ever I am on the BackOffice, sub menus dont-appear and notifications are not there. The only place where sub menus work are when i click on CATALOG, the rest of the panel is not "Updating the notifications" therefore not letting me navigate the backoffice. Here are two photos explaining this situation.
 
I also get this error: 
notifications.js:29   Uncaught ReferenceError: autorefresh_notifications is not defined(…)

 

Picture describing it, keeps loading for ever and nothing works.
 post-1349137-0-57825000-1481391105_thumb.png

 

When I am inside the Catalog and it loads for 1 second then everything works.

post-1349137-0-90610000-1481391556_thumb.png

$(document).ready(function() {
	var hints = $('.translatable span.hint');
	if (youEditFieldFor)
		hints.html(hints.html() + '<br /><span class="red">' + youEditFieldFor + '</span>');

	var html = "";		
	var nb_notifs = 0;
	var wrapper_id = "";
	var type = new Array();
	
	$(".notifs").click(function(){
		var wrapper_id = $(this).parent().attr("id");

		$.post(
			"ajax.php",
			{
				"updateElementEmployee" : "1",
				"updateElementEmployeeType" : $(this).parent().attr('data-type')
			},
			function(data) {
				if (data) {
					$("#" + wrapper_id + "_value").html(0);
					$("#" + wrapper_id + "_number_wrapper").hide();
				}				
			}
		);
	});
	// call it once immediately, then use setTimeout if refresh is activated
	getPush(autorefresh_notifications);

});

function getPush(refresh)
{
	$.ajax({
		type: 'POST',
		headers: {"cache-control": "no-cache"},
		url: 'ajax.php?rand=' + new Date().getTime(),
		async: true,
		cache: false,
		dataType : 'json',
		data: {"getNotifications" : "1"},
		success: function(json) {
			if (json)
			{
				// Set moment language
				moment.lang(full_language_code);
				
				// Add orders notifications to the list
				html = "";
				$.each(json.order.results, function(property, value) {
					html += "<a href='index.php?tab=AdminOrders&token=" + token_admin_orders + "&vieworder&id_order=" + parseInt(value.id_order) + "'>";
					html += "<p>" + order_number_msg + " <strong>#" + parseInt(value.id_order) + "</strong></p>";
					html += "<p class='pull-right'>" + total_msg + " <span class='total badge badge-success'>" + value.total_paid + "</span></p>";
					html += "<p>" + from_msg + " <strong>" + value.customer_name + "</strong></p>";
					html += "<small class='text-muted'><i class='icon-time'></i> " +  moment(value.update_date).fromNow() + " </small>";
					html += "</a>";
				});
				if (parseInt(json.order.total) > 0)
				{
					$("#list_orders_notif").empty().append(html);
					$("#orders_notif_value").text(json.order.total);
					$("#orders_notif_number_wrapper").removeClass('hide');
				}
				else
					$("#orders_notif_number_wrapper").addClass('hide');
				// Add customers notifications to the list
				html = "";
				$.each(json.customer.results, function(property, value) {
					html += "<a href='index.php?tab=AdminCustomers&token=" + token_admin_customers + "&viewcustomer&id_customer=" + parseInt(value.id_customer) + "'>";
					html += "<p>" + customer_name_msg + " <strong>#" + value.customer_name + "</strong></p>";
					html += "<small class='text-muted'><i class='icon-time'></i> " +  moment(value.update_date).fromNow() + " </small>";
					html += "</a>";
				});
				if (parseInt(json.customer.total) > 0)
				{
					$("#list_customers_notif").empty().append(html);
					$("#customers_notif_value").text(json.customer.total);
					$("#customers_notif_number_wrapper").removeClass('hide');
				}
				else
					$("#customers_notif_number_wrapper").addClass('hide');
				// Add messages notifications to the list
				html = "";
				$.each(json.customer_message.results, function(property, value) {
					html += "<a href='index.php?tab=AdminCustomerThreads&token=" + token_admin_customer_threads + "&viewcustomer_thread&id_customer_thread=" + parseInt(value.id_customer_thread) + "'>";
					html += "<p>" + from_msg + " <strong>" + value.customer_name + "</strong></p>";
					html += "<small class='text-muted'><i class='icon-time'></i> " +  moment(value.update_date).fromNow() + " </small>";
					html += "</a>";
				});
				if (parseInt(json.customer_message.total) > 0)
				{
					$("#list_customer_messages_notif").empty().append(html);
					$("#customer_messages_notif_value").text(json.customer_message.total);
					$("#customer_messages_notif_number_wrapper").removeClass('hide');
				}
				else
					$("#customer_messages_notif_number_wrapper").addClass('hide');
			}
			if (refresh)
				setTimeout("getPush(1)", 120000);
		}
	});
}

Share this post


Link to post
Share on other sites

This is late but looking for the answer for this exact issue and fixed it. Don't edit anything. Go in the back office and under "Performance", clear the cache. Then, clear your browser cache. 

 

Not sure why this works.

Share this post


Link to post
Share on other sites

I had the same issue in PrestaShop 1.7.5.2 after migration from PrestaShop 1.6 shop in the same domain. The error was being caused by a cached version of /js/admin/notifications.js in my browser (the 1.6 version was being loaded). Clearing the browser cache fixed the issue.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More