Page 1 of 1

Newsletter module for OpenCart 2.0.2.0

Posted: Thu Oct 27, 2016 12:45 am
by SubatWest
Hi

Has anyone used this extension.
https://www.opencart.com/index.php?rout ... _license=0

It does a good job but does not seem to complete the task and whilst it acknowledges the unsubscribe with the correct message it does not clear the entry box after a new email nor issue a success message. It does add the email to the database. Have tried to contact the author but no success. Any ideas?

Thanks

Re: Newsletter module for OpenCart 2.0.2.0

Posted: Thu Oct 27, 2016 3:05 am
by cyclops12
That would be because the module is for 2.0.2.0 and you are using 2.1.0.1.......they are different!!!

Re: Newsletter module for OpenCart 2.0.2.0

Posted: Thu Oct 27, 2016 3:43 am
by SubatWest
Yes I understand that but the coding and referencing within the module are not in conflict with OC version, as far as I can see. As I say the module slots into place and runs up until the execution of the end command. I noted that back in Apr another user posted the same issue but followed it up with a quote he had 'fixed it' but frustratingly he did not say how! By the way I have other version modules running on my version that are 2x.

Re: Newsletter module for OpenCart 2.0.2.0

Posted: Thu Oct 27, 2016 5:49 pm
by cyclops12
Ok i shall try it out tonight if i get time and let you know if it works for me

Re: Newsletter module for OpenCart 2.0.2.0

Posted: Sun Oct 30, 2016 10:56 pm
by SubatWest
Hi
Did you ahve any comments re your trial?
Thanks

Re: Newsletter module for OpenCart 2.0.2.0

Posted: Mon Oct 31, 2016 12:31 am
by cyclops12
Yeah sorry for the late reply...
I installed this on a fresh default 2.0.3.1 version and it seems to be ok, not sure what im supposed to be looking for but the messages appear and email clears when subscribing
subscribe.JPG

subscribe.JPG (29.28 KiB) Viewed 1659 times

and unsubscribing
unsubscribe.JPG

unsubscribe.JPG (28.8 KiB) Viewed 1659 times


Re: Newsletter module for OpenCart 2.0.2.0

Posted: Mon Oct 31, 2016 12:47 am
by cyclops12
Another thing to add is this looks ok in "content bottom" but wont fit in left or right column layout

Also am getting error message:
Error.JPG

Error.JPG (19.72 KiB) Viewed 1658 times

so looking into that :)

EDIT: in said file on line 42 you have

Code: Select all

<div class="row" id="newsletter<?php echo $module; ?>">
I changed it to

Code: Select all

<div class="row" id="newsletter">
and no more error message and all still works

Re: Newsletter module for OpenCart 2.0.2.0

Posted: Mon Oct 31, 2016 7:22 am
by SubatWest
Thanks for that.
I tried the change but no effect. Despite the appearance that everything is similar in structure to the different OC versions there is obviously a difference as you originally wrote. Will investigate further.
Thanks

Re: Newsletter module for OpenCart 2.0.2.0

Posted: Mon Oct 31, 2016 6:26 pm
by SubatWest
Hi
Have checked everything and there is no reason obvious as to why the extension is not functioning correctly. When I unsubscribe it's fine.
1_2016-10-31 10_10_02-Your Store.png

When I unsubscribe. iget the following: - 1_2016-10-31 10_10_02-Your Store.png (8.55 KiB) Viewed 1639 times

When I immediately subscribe another email without cancelling the message I get the following :
2_2016-10-31 10_11_02-Your Store.png

2_2016-10-31 10_11_02-Your Store.png (9.09 KiB) Viewed 1639 times

The message does not disappear and no success message appears BUT the email does get posrted!

Then in a fresh entering of an email I get after 'Loading' appears:
3_2016-10-31 10_17_42-Your Store.png

3_2016-10-31 10_17_42-Your Store.png (6.9 KiB) Viewed 1639 times

Again no success message BUT the email does get posted.
The .tpl scrip appears fine:

Code: Select all

<script language="javascript">
jQuery(document).ready(function($) {
	$('#lt_newsletter_form').submit(function(){
		$.ajax({
			type: 'post',
			url: '<?php echo $action; ?>',
			data:$("#lt_newsletter_form").serialize(),
			dataType: 'json',			
			beforeSend: function() {
				$('.btn-newsletter').attr('disabled', true).button('loading');
			},	
			complete: function() {
				$('.btn-newsletter').attr('disabled', false).button('reset');
			},				
			success: function(json) {
				$('.alert, .text-danger').remove();
				$('.form-group').removeClass('has-error');

				if (json.error) {
					$('#lt_newsletter_module').after('<div class="alert alert-danger newsletter-msg">' + json.error + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
				} else {
					$('#lt_newsletter_module').after('<div class="alert alert-success newsletter-msg">' + json.success + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
					$('#lt_newsletter_email').val('');
				}
			}

		});
		return false;
	});
});
</script>   
and the calling code also seems fine:

Code: Select all

	public function subscribe()
	{
		$this->load->language('module/lt_newsletter');
		
		$this->load->model('module/lt_newsletter');

		if (($this->request->server['REQUEST_METHOD'] == 'POST'))
		{
			$email = $this->request->post['lt_newsletter_email'];
			
			if ((utf8_strlen($email) > 96) || !preg_match('/^[^\@]+@.*.[a-z]{2,15}$/i', $email)) {
				$json['error'] = $this->language->get('error_invalid');
			}
			else{
				$row = $this->model_module_lt_newsletter->row($email);
			
      	if($row)
				{
					$this->model_module_lt_newsletter->unsubscribe($email);
					$json['success'] = $this->language->get('text_unsubscribed');
				}
				else{
					$this->model_module_lt_newsletter->subscribe($email);
					$json['success'] = $this->language->get('text_subscribed');
          
         
The

Code: Select all

$this->model_module_lt_newsletter->unsubscribe($email);
					$json['success'] = $this->language->get('text_unsubscribed');
does work BUT the

Code: Select all

$this->model_module_lt_newsletter->subscribe($email);
					$json['success'] = $this->language->get('text_subscribed');
does not.

I have tried to contact the author directly and through other posts but no response. So I am stumped.
:(

Re: Newsletter module for OpenCart 2.0.2.0

Posted: Mon Oct 31, 2016 8:50 pm
by cyclops12
Well as long as all the files were uploaded correctly then i can only assume that another mod/extension is conflicting with it somehow as it works as it should on a default 2.0.3.1 with no extra extensions/mods installed

Depending on how many extra mods you have installed you could disable them one at a time and retry the newsletter module until you come across the culprit. Remember to refresh each time though ;D

Re: Newsletter module for OpenCart 2.0.2.0

Posted: Tue Nov 01, 2016 5:34 pm
by SubatWest
Just to close this subject.
The issue was a conflict between xaamp and the module it appears. When I moved the site outside the xaamp enviorment it worked first time.

Re: Newsletter module for OpenCart 2.0.2.0

Posted: Tue Nov 01, 2016 5:52 pm
by cyclops12
Hmm bit annoying but at least you got it working ;D