Jump to content

Auto retrieve customer mails in customer service


westsoftdevelopment

Recommended Posts

  • 2 months later...

a chron job would be ideal, anyway if you want a temporary solution you can do the following:

 

edit the file in your admin folder

themes/default/template/controllers/customer_threads/helpers/options/options.tpl

 

replace the content with this:

 

{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{extends file="helpers/options/options.tpl"}
{block name="after"}
{if $use_sync}
		<fieldset><legend>{l s='Sync'}</legend>
			<label>{l s='Run sync:'}</label>
			<div class="margin-form">
				<button class="button" id="run_sync" onclick="run_sync();">{l s='Run sync'}</button>
				<p>{l s='Click to synchronize mail automatically'}</p>
				<div id="ajax_loader"></div>
				<div class="error" style="display:none" id="ajax_error"></div>
				<div class="conf" style="display:none" id="ajax_conf"></div>
			</div>
		</fieldset><br/>
                <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.3.1/jquery.cookie.min.js"></script>
		<script type="text/javascript"> 
			var ajaxQueries = new Array();
			function run_sync()
			{
				$('#ajax_error').html('');
				$('#ajax_error').hide();
				$('#ajax_conf').html('');
				$('#ajax_conf').hide();
				for(i = 0; i < ajaxQueries.length; i++)
					ajaxQueries[i].abort();
				ajaxQueries = new Array();
				$('#ajax_loader').html('<img src="{$smarty.const._PS_ADMIN_IMG_}ajax-loader.gif">');
				ajaxQuery = $.ajax({
					type: "POST",
					cache: false,
					url: "index.php",
					data: {
						ajax: "1",
						token: "{$token}", 
						syncImapMail: "1",
						ajax:"1",
						action:"syncImap",
						tab:"AdminCustomerThreads"
					},
					dataType : "json",
					success: function(jsonData) {
						jsonError = '';
						if (jsonData.hasError)
						{
							for (i=0;i < jsonData.errors.length;i++)
								jsonError = jsonError+'<li>'+jsonData.errors[i]+'</li>';
							$('#ajax_error').html('<ul>'+jsonError+'</ul>');
							$('#ajax_error').fadeIn();
						}
						else
						{
							jsonError = '<li>{l s='Sync success'}</li>';
							for (i=0;i < jsonData.errors.length;i++)
								jsonError = jsonError+'<li>'+jsonData.errors[i]+'</li>';
							$('#ajax_conf').html('<ul>'+jsonError+'</ul>');
							$('#ajax_conf').fadeIn();
						}
							
						$('#ajax_loader').html('');
					},
					error: function(XMLHttpRequest, textStatus, errorThrown)
					{
						jAlert("TECHNICAL ERROR: unable to sync.\n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
					}
				});
				ajaxQueries.push(ajaxQuery);
				
			};
			$(document).ready(function(){  //Syncrea Sincronizzazione automatica
				
				if ($.cookie('syncCookie') == 'true') {
					 // do nothing
				} else {
					var date = new Date();
					var minutes = 20;
					date.setTime(date.getTime() + (minutes * 60 * 1000));
					$.cookie('syncCookie', 'true', { expires: date });
					run_sync();
				}
			
			})
		
		</script>
{/if}
{/block}

this will sync the mail automatically (when you open the customer threads tab) once every 20 minutes,  you can change the timing simply editing the variable
"var minutes = 20;"

Enjoy!

Link to comment
Share on other sites

  • 3 months later...

Hi I tried what you did, adding

			$(document).ready(function(){  //Syncrea Sincronizzazione automatica
				
				if ($.cookie('syncCookie') == 'true') {
					 // do nothing
				} else {
					var date = new Date();
					var minutes = -1;
					date.setTime(date.getTime() + (minutes * 60 * 1000));
					$.cookie('syncCookie', 'true', { expires: date });
					run_sync();
				}
			
			})

to options.tpl but it doesn't seem to work. Is there aything I missed out?

 

Thanks

Link to comment
Share on other sites

that is not enough, I posted the full code you should use to make it work in comment number 2 or add at least the jquery plugin to handle cookies

<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.3.1/jquery.cookie.min.js"></script>

at the top of option.tpl.

Link to comment
Share on other sites

  • 3 months later...

a chron job would be ideal, anyway if you want a temporary solution you can do the following:

 

edit the file in your admin folder

 

themes/default/template/controllers/customer_threads/helpers/options/options.tpl

 

replace the content with this:

 

 

{*
* 2007-2013 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
{extends file="helpers/options/options.tpl"}
{block name="after"}
{if $use_sync}
		<fieldset><legend>{l s='Sync'}</legend>
			<label>{l s='Run sync:'}</label>
			<div class="margin-form">
				<button class="button" id="run_sync" onclick="run_sync();">{l s='Run sync'}</button>
				<p>{l s='Click to synchronize mail automatically'}</p>
				<div id="ajax_loader"></div>
				<div class="error" style="display:none" id="ajax_error"></div>
				<div class="conf" style="display:none" id="ajax_conf"></div>
			</div>
		</fieldset><br/>
                <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.3.1/jquery.cookie.min.js"></script>
		<script type="text/javascript"> 
			var ajaxQueries = new Array();
			function run_sync()
			{
				$('#ajax_error').html('');
				$('#ajax_error').hide();
				$('#ajax_conf').html('');
				$('#ajax_conf').hide();
				for(i = 0; i < ajaxQueries.length; i++)
					ajaxQueries[i].abort();
				ajaxQueries = new Array();
				$('#ajax_loader').html('<img src="{$smarty.const._PS_ADMIN_IMG_}ajax-loader.gif">');
				ajaxQuery = $.ajax({
					type: "POST",
					cache: false,
					url: "index.php",
					data: {
						ajax: "1",
						token: "{$token}", 
						syncImapMail: "1",
						ajax:"1",
						action:"syncImap",
						tab:"AdminCustomerThreads"
					},
					dataType : "json",
					success: function(jsonData) {
						jsonError = '';
						if (jsonData.hasError)
						{
							for (i=0;i < jsonData.errors.length;i++)
								jsonError = jsonError+'<li>'+jsonData.errors[i]+'</li>';
							$('#ajax_error').html('<ul>'+jsonError+'</ul>');
							$('#ajax_error').fadeIn();
						}
						else
						{
							jsonError = '<li>{l s='Sync success'}</li>';
							for (i=0;i < jsonData.errors.length;i++)
								jsonError = jsonError+'<li>'+jsonData.errors[i]+'</li>';
							$('#ajax_conf').html('<ul>'+jsonError+'</ul>');
							$('#ajax_conf').fadeIn();
						}
							
						$('#ajax_loader').html('');
					},
					error: function(XMLHttpRequest, textStatus, errorThrown)
					{
						jAlert("TECHNICAL ERROR: unable to sync.\n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
					}
				});
				ajaxQueries.push(ajaxQuery);
				
			};
			$(document).ready(function(){  //Syncrea Sincronizzazione automatica
				
				if ($.cookie('syncCookie') == 'true') {
					 // do nothing
				} else {
					var date = new Date();
					var minutes = 20;
					date.setTime(date.getTime() + (minutes * 60 * 1000));
					$.cookie('syncCookie', 'true', { expires: date });
					run_sync();
				}
			
			})
		
		</script>
{/if}
{/block}

this will sync the mail automatically (when you open the customer threads tab) once every 20 minutes,  you can change the timing simply editing the variable

"var minutes = 20;"

 

Enjoy!

in which file I have to change the "var minutes = 20;" value could you please specify ?

Also this solutions does works for PS 1.5.4.1 

 

post-411458-0-90242900-1404373204_thumb.jpg

post-411458-0-23150300-1404373207_thumb.jpg

Edited by lovemyseo (see edit history)
Link to comment
Share on other sites

you quoted my message where is specidfied the file and there is the file content:

 

themes/default/template/controllers/customer_threads/helpers/options/options.tpl

Ok done above but still unable to see Customer messages options as customer thread in back office just like I was able to see in PS 149 

post-411458-0-01012700-1404377792_thumb.jpg

post-411458-0-43858600-1404377799_thumb.jpg

Link to comment
Share on other sites

  • 4 months later...
  • 8 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...