Post by madfish » Fri Nov 09, 2012 2:48 am

Hello,

i have a problem, as I have multi-store so also multi-language store. The problem is that when I click "Add reward points" in admin/orders . The mail comes out in the ADMIN LANGUAGE and not in the default store language. I use OC 1.5.1.3, any solution to this problem would be really apreciated. Thanks.

My fragrance parfum site profumi


New member

Posts

Joined
Thu Dec 03, 2009 8:49 pm


Post by madfish » Fri Nov 09, 2012 5:18 pm

the whole /admin/model/sale/customer.php is sending out emails in the ADMIN LANGUAGE instead of the chosen one. Any fixes ?

My fragrance parfum site profumi


New member

Posts

Joined
Thu Dec 03, 2009 8:49 pm


Post by madfish » Sat Nov 10, 2012 5:58 pm

Anyone?

My fragrance parfum site profumi


New member

Posts

Joined
Thu Dec 03, 2009 8:49 pm


Post by tolinho » Sun Dec 23, 2012 5:09 am

Hi,
I have the same problem.
I have two languages installed.
I use the Admin section in English.
When I update an order status, the customer receives the e-mail in the language he placed the order.
When I press "Add Reward Points" he receives an e-mail in the Admin language, and not the language he placed the order.

Im running version 1541

New member

Posts

Joined
Sat Jul 21, 2012 2:01 am

Post by rinapharm » Mon Mar 11, 2013 5:04 am

Hello,

I had the same problem and I solved it this way.
I hope this helps everyone.

Should go to the next file and edit it:
admin/model/sale/customer.php

search the line:
"public function addReward"
after few lines (about 6), remove the line: " $this->language->load('mail/customer'); "

after following lines insert this code:
---------------------------------------after following lines-----------------------------------
if ($order_id) {
$this->load->model('sale/order');

$order_info = $this->model_sale_order->getOrder($order_id);

if ($order_info) {
$store_name = $order_info['store_name'];
} else {
$store_name = $this->config->get('config_name');
}
} else {
$store_name = $this->config->get('config_name');
}
----------------------------------------------insert (add) this code------------------------------------

// ---------ADD---------------
$this->load->model('localisation/language');
$language = new Language($order_info['language_directory']);
$language->load($order_info['language_filename']);
$language->load('mail/customer');
// ---------END ADDING---------------

-------------------------------------------END---------------------------------

On the following lines
CHANGE this code: $this->language
TO this: $language

-----------------------------------CHANGE $this->language TO $language --------------------------

$message = sprintf($language->get('text_reward_received'), $points) . "\n\n";
$message .= sprintf($language->get('text_reward_total'), $this->getRewardTotal($customer_id));
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($customer_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($store_name);
$mail->setSubject(html_entity_decode(sprintf($language->get('text_reward_subject'), $store_name), ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
$mail->send();

--------------------------------------------------------END CHANGE---------------------------------------------

And now the customer will recived mail by his order language.
Now we need to change the comment line in the rewards customer area.
I did it will record only the order number.

go up few lines to:
if ($customer_info) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward SET customer_id = '" . (int)$customer_id . "', order_id = '" . (int)$order_id . "', points = '" . (int)$points . "', description = '" .$this->db->escape($description) . "', date_added = NOW()");

change this code:
description = '" . $this->db->escape($description) . "'

to this code:
description = '" . (int)$order_id . "'

The new code should look like this:
-----------------------------------------------NEW CODE------------------------------------------------
public function addReward($customer_id, $description = '', $points = '', $order_id = 0) {
$customer_info = $this->getCustomer($customer_id);

if ($customer_info) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward SET customer_id = '" . (int)$customer_id . "', order_id = '" . (int)$order_id . "', points = '" . (int)$points . "', description = '" . (int)$order_id . "', date_added = NOW()");

if ($order_id) {
$this->load->model('sale/order');

$order_info = $this->model_sale_order->getOrder($order_id);

if ($order_info) {
$store_name = $order_info['store_name'];
} else {
$store_name = $this->config->get('config_name');
}
} else {
$store_name = $this->config->get('config_name');
}

$this->load->model('localisation/language');
$language = new Language($order_info['language_directory']);
$language->load($order_info['language_filename']);
$language->load('mail/customer');


$message = sprintf($language->get('text_reward_received'), $points) . "\n\n";
$message .= sprintf($language->get('text_reward_total'), $this->getRewardTotal($customer_id));
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($customer_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($store_name);
$mail->setSubject(html_entity_decode(sprintf($language->get('text_reward_subject'), $store_name), ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
$mail->send();
}
}
---------------------------------------------------END----------------------------------------------------

Thats is all.
I hope I help someone. Good luck.

Newbie

Posts

Joined
Mon Mar 11, 2013 3:40 am

Post by tolinho » Tue Mar 12, 2013 1:05 am

hi rinapharm,
Thanks for sharing this fix.
I don't supose you mada a vqmod for this? :)

If not I will try to make the changes manually.

New member

Posts

Joined
Sat Jul 21, 2012 2:01 am

Post by ase618 » Tue Mar 12, 2013 1:18 am

Why don't you create the vQmod yourself? Rinapharm already gave you the code. Creating the vQmod is the easy part and shouldn't take very long. You can help everybody else out in return for Rinapharm helping you;-)

artisantool.co
Don't forget to add [SOLVED] to your Thread Title (first post), if your issue is solved.


Active Member

Posts

Joined
Sun Jul 29, 2012 9:59 pm

Post by rinapharm » Tue Mar 12, 2013 1:21 am

I found more one problem...
So i fix it and work for the vqmode...

Newbie

Posts

Joined
Mon Mar 11, 2013 3:40 am

Post by tolinho » Tue Mar 12, 2013 1:41 am

Hi ase618
I think there is no harm in asking :) no offence there.
If there is a vqmod made already, maybe rinapharm would share it, if not of course I would try and make it.

I'm not a programmer, but still, I feel I help everyone else once in a while how I can.
In fact, I have shared a couple of things including vqmods on other topics and threads.

Once again, thank you rinapharm for sharing.

New member

Posts

Joined
Sat Jul 21, 2012 2:01 am

Post by rinapharm » Tue Mar 12, 2013 2:51 am

ok!
i dont know why i dont sucsesfull so -> delete the following code and copy the other code...
i found when i put my code (previous code I wrote here) i cant sent reward without order (if i want to add a reward to customer from the admin panel without an order) so now we have other fix code:

admin/model/sale/customer.php
find this code and delete:
------------------------------------------------------------
public function addReward($customer_id, $description = '', $points = '', $order_id = 0) {
$customer_info = $this->getCustomer($customer_id);

if ($customer_info) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward SET customer_id = '" . (int)$customer_id . "', order_id = '" . (int)$order_id . "', points = '" . (int)$points . "', description = '" . $this->db->escape($description) . "', date_added = NOW()");

$this->language->load('mail/customer');

if ($order_id) {
$this->load->model('sale/order');

$order_info = $this->model_sale_order->getOrder($order_id);

if ($order_info) {
$store_name = $order_info['store_name'];
} else {
$store_name = $this->config->get('config_name');
}
} else {
$store_name = $this->config->get('config_name');
}

$message = sprintf($this->language->get('text_reward_received'), $points) . "\n\n";
$message .= sprintf($this->language->get('text_reward_total'), $this->getRewardTotal($customer_id));

$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($customer_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($store_name);
$mail->setSubject(html_entity_decode(sprintf($this->language->get('text_reward_subject'), $store_name), ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
$mail->send();
}
}

------------------------------------------------------------


add this code:
------------------------------------------------------------
public function addReward($customer_id, $description = '', $points = '', $order_id = 0)
{
$customer_info = $this->getCustomer($customer_id);
if ($customer_info)
{
if ($order_id)
{
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward SET customer_id = '" . (int)$customer_id . "', order_id = '" . (int)$order_id . "', points = '" . (int)$points . "', description = '" . (int)$order_id . "', date_added = NOW()");
$this->load->model('sale/order');
$order_info = $this->model_sale_order->getOrder($order_id);
if ($order_info)
{
$store_name = $order_info['store_name'];
}
else
{
$store_name = $this->config->get('config_name');
}
$this->load->model('localisation/language');
$language = new Language($order_info['language_directory']);
$language->load($order_info['language_filename']);
$language->load('mail/customer');
$message = sprintf($language->get('text_reward_received'), $points) . "\n\n";
$message .= sprintf($language->get('text_reward_total'), $this->getRewardTotal($customer_id)) . "\n\n";
$message .= $language->get('text_reward_end');
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($customer_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($store_name);
$mail->setSubject(html_entity_decode(sprintf($language->get('text_reward_subject'), $store_name), ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
$mail->send();

}

else
{
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_reward SET customer_id = '" . (int)$customer_id . "', order_id = '" . (int)$order_id . "', points = '" . (int)$points . "', description = '" . $this->db->escape($description) . "', date_added = NOW()");

$store_name = $this->config->get('config_name');
$this->load->language('mail/customer');
$message = sprintf($this->language->get('text_reward_received'), $points) . "\n\n";
$message .= sprintf($this->language->get('text_reward_total'), $this->getRewardTotal($customer_id)) . "\n\n";
$message .= $this->language->get('text_reward_end');
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($customer_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($store_name);
$mail->setSubject(html_entity_decode(sprintf($this->language->get('text_reward_subject'), $store_name), ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
$mail->send();
}
}
}

------------------------------------------------------------

Newbie

Posts

Joined
Mon Mar 11, 2013 3:40 am

Post by paradoxx » Thu Nov 28, 2013 4:00 am

Did anyone tried this already? I made the changes and Ive got an error and I couldnt open the order.

New member

Posts

Joined
Sun Jun 30, 2013 5:56 am
Who is online

Users browsing this forum: No registered users and 87 guests