JNeuhoff wrote:I think you are talking about the
catalog/model/checkout/order.php where the original has this:
Code: Select all
// Send out order confirmation mail
$language = new Language($order_info['language_directory']);
$language->load($order_info['language_filename']);
$language->load('mail/order');
The version with the Override Engine uses this:
Code: Select all
// Send out order confirmation mail
$language = $this->factory->newLanguage($order_info['language_directory']);
$language->load($order_info['language_filename']);
$language->load('mail/order');
To narrow down your problem, change it back to the original lines and let me know if you still get the same problem. Then we can see whether this is the issue.
Hello,
I had a... let's say "
busy" 2 months but in the end I could test this suggestion of yours.
Indeed as soon as I restored the original code, the emails started being delivered in the correct language.
I have noticed a similar issue on my own code that hints at what's going wrong on yours: I had to write a TON of webshop specific rules (several kinds of buyers, each with different terms, documents and emails to send).
These rules would work in a most awesome way as long as the buyers purchased through bank transfer or direct debit but would just disappear when purchasing through Paypal or credit card.
I tracked down the issue in the low level OpenCart callback workings: the bank transfer and direct debit modules call the catalog/model/checkout/order.php functions:
public function confirm($order_id, $order_status_id, $comment = '', $notify = false);
and
public function update($order_id, $order_status_id, $comment = '', $notify = false);
from
within the OpenCart context, that is, an OpenCart function calls those functions. And by consequence, the whole OpenCart environment ($_POST, session, cookies) is available to them.
On the contrary, when the Paypal / credit card / whatever modules are used, they do their stuff and then redirect the buyer to a third party payment gateway. The third party payment gateway does not know anything about the current OpenCart environment, it just "strips" everything out. Then, once the payment has been completed, the third party payment gateway calls the above functions as "callbacks"... but hey, as I said, it lost the whole OpenCart context so the callbacks are called without any OpenCart variable, session, cookie.
Therefore, those callbacks must be able to "rebuild" the lost context back up from scratch. That's why there's a whole "new Language" re-initialization. That's why in my code, given the order ID, I too had to restore everything from scratch.
In your case, by using the factory, you are trying to re-use a context that only stays when calling internal payment modules like bank transfer and direct debit. The external gateways destroy ALL including your objects, therefore when the callback is called it calls an uninitialized object. It silently fails, the next calls load translations on a "fresh" language variable which by default starts in English and therefore that's the language that ends up in the order emails.