Post by gclass » Mon Oct 12, 2009 5:00 pm

Hello,
I would like to align to text in email Opencart sends to be RTL.
can you point how should it be done?

Thx
G

New member

Posts

Joined
Sat Oct 03, 2009 1:21 am

Post by Daniel » Mon Oct 12, 2009 8:21 pm

you need to look at the main language file. like english.php and change the direction.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by gclass » Tue Oct 13, 2009 1:07 am

hi Daniel,

I did it before, but the email are still LTR.

New member

Posts

Joined
Sat Oct 03, 2009 1:21 am

Post by gclass » Wed Oct 14, 2009 1:06 am

Hi Daniel,
We use 'direction : rtl;' to align texts in the code sometimes.
the solution within the language main file is not affecting email opencart send.

can you point the part in the code that build and send the email so I can try to solve it,
or if you can think of a place I should add 'direction:rtl;' line,

thanks

G

New member

Posts

Joined
Sat Oct 03, 2009 1:21 am

Post by gclass » Sun Nov 01, 2009 3:47 pm

Hi Daniel and the others,

can someone please point the code that handles the emails so I can try to fix it?

is there anyone else here using Opencart with right to left language?

Thx

New member

Posts

Joined
Sat Oct 03, 2009 1:21 am

Post by gclass » Sun Nov 01, 2009 6:21 pm

OK, I found the code that deal with emails, and read about mail() function.
the solution is to send the email as HTML so it will be RTL.
the only problem now I cant send $headers to the mail() function.

please take a look at the code I changed and see if you know how can I fix the 3rd row from bottom as for now I get this error:
Fatal error: Call to undefined method Mail::setHeaders() in admin/model/customer/order.php on line 42

I set to bold and italic my additions:

Code: Select all

$subject = sprintf($language->get('mail_subject'), $this->config->get('config_store'), $order_id);
	
				[b]$message  = '<html dir="RTL"><body>';[/b][i][/i]
				$message .= $language->get('mail_order') . ' ' . $order_id . "\n";
				$message .= $language->get('mail_date_added') . ' ' . date($language->get('date_format_short'), strtotime($query->row['date_added'])) . "\n\n";
				$message .= $language->get('mail_order_status') . "\n\n";
				$message .= $query->row['status'] . "\n\n";
					
				$message .= $language->get('mail_invoice') . "\n";
				$message .= html_entity_decode(HTTP_CATALOG . 'index.php?route=account/invoice&order_id=' . $order_id) . "\n\n";
					
				if (isset($data['comment'])) { 
					$message .= $language->get('mail_comment') . "\n\n";
					$message .= strip_tags(html_entity_decode($data['comment'])) . "\n\n";
				}
					
				$message .= $language->get('mail_footer');
				[b]$message .= '</html></body>';[/b][i][/i]

               [i] $headers  = 'MIME-Version: 1.0' . "\r\n";
                $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; 
                 [/i][b][/b]
				$mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password')), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
	    		$mail->setTo($query->row['email']);
				$mail->setFrom($this->config->get('config_email'));
	    		$mail->setSender($this->config->get('config_store'));
	    		$mail->setSubject($subject);
			[i]$mail->setHeaders($headers);[/i][b][/b]
	    		$mail->setText($message);
	    		$mail->send();

New member

Posts

Joined
Sat Oct 03, 2009 1:21 am

Post by gclass » Fri Jan 15, 2010 5:17 am

Hi All,

sorry for bumping this one.

my site is getting more and more traffic lately and I still having problems with aligning the email to the right.
I use Hebrew which is right-to-left language, and I cant align the email to be send with the text aligned to the right (RTL).

I would really appreciate any help with it,

Regards,
G

New member

Posts

Joined
Sat Oct 03, 2009 1:21 am

Post by amplifywebdesign » Fri Jan 15, 2010 5:53 am

I think it is going wrong because you have added a <html> and <body> tag after there is already one present (this is because the variable $message is not the start of the message (please correctly if I am wrong, this is a assumption)

If you want a way that is certain to work then use the html email contrib located here:

http://forum.opencart.com/viewtopic.php ... 59&start=0

Here you can find the <html> tag and add the text direction thing at the top and it shouldn't complain.

You could also try <p dir="RTL">...... </p> but I am not sure if text direction can be applied to individual paragraphs, but a few things to try none the less!

User avatar
New member

Posts

Joined
Sat Aug 22, 2009 1:56 am
Location - Sheffield & North Wales
Who is online

Users browsing this forum: No registered users and 10 guests