Jump to content

[SOLUTION] How to use order_conf variables in any email template.


mpdas108

Recommended Posts

So after two days of searching I have created a OrderHistory.php that you can place in your overrides directory that will allow you to use all of the default order_conf variables in any email template.

 

Just place the attached file in your PRESTASHOP_HOME/override/classes/order/ directory.

 

If you find any bug or mistakes in the code please let me know. Also if you have your own code that adds other variables to OrderHistory.php, then please merge with this one and post in this thread, Im sure it will be useful for other people.

 

List of variables that are added for use with this file:

 

{lastname}

{firstname}

{id_order}

{order_name}

{delivery_block_txt}

{invoice_block_txt}

{delivery_block_html}

{invoice_block_html}

{delivery_company}

{delivery_firstname}

{delivery_lastname}

{delivery_address1}

{delivery_address2}

{delivery_city}

{delivery_postal_code}

{delivery_country}

{delivery_state}

{delivery_phone}

{delivery_other}

{invoice_company}

{invoice_vat_number}

{invoice_firstname}

{invoice_lastname}

{invoice_address2}

{invoice_address1}

{invoice_city}

{invoice_postal_code}

{invoice_country}

{invoice_state}

{invoice_phone}

{invoice_other}

{order_name}

{date}

{carrier}

{payment}

{products}

{total_paid}

{total_products}

{total_discounts}

{total_shipping}

{total_wrapping}

{total_tax_paid}

 

This is tested and working on 1.6.0.14. Any other versions you can try on your own.

OrderHistory.php

Edited by mpdas108 (see edit history)
  • Like 9
Link to comment
Share on other sites

  • 3 weeks later...

I don't even have a "Resend Email" button, I'm using 1.6.0.14. Maybe it is a new feature in 1.6.1.1 

 

EDIT: I just checked the revision history: [*] BO : #PSCSX-2149 Add the possibility to re-send the order emails

 

So this "Resend Email" is a new feature, along with many other features and bug fixes with version 1.6.1.0 and 1.6.1.1

 

Im not running the latest version, so if you want to check it out and see what has changed to cause this issue, you would perhaps help other people.

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

  • 2 weeks later...
  • 2 weeks later...
  • 2 weeks later...

If you change status whilst in "All Shops" then the links will send you to the default store rather than the store the item was ordered from (in the case of {products}).

 

I've modified this to use the store rather than the context and attached the file

Link to comment
Share on other sites

  • 2 months later...

Hello,

i'm trying to add some variables to my emails but dosent works.

If i take for exemple the valaue {date} from order_conf.html and place it into payment.html, when i try to send the email i recieve a mail with {date} into the body test of my email.

Anyone can help me? i'm running PS 1.6.1.3 (last update).

I've tryed with translations, with overraie and i'm going crazy...

Thnaks

G.F.

Link to comment
Share on other sites

  • 8 months later...
  • 3 months later...
  • 1 month later...
  • 1 month later...

I could work out a solution that works in 1.6.11.

One thing I didn't check is if the product-attributes are correct. There could be other problems, too - but it works fine for me so far!

I slightly changed my file berfore attaching (so it works with any email-template, as I use a if-clause that it works only on specific email-templates for speed reasons) - I hope I didn't make a mistake :rolleyes: . All variables used in the 'orderconf'-template should be in there now.

 

I hope you can use this file! Have fun!

OrderHistory.php

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

oops... found some bugs: The carrier name didn't work and furthermore all the single delivery/invoice-fields...

I updated the file and left my if-clause in there commented out. So if you want, you just can use the if-clause in line 420 for you email-templates and bring back the 'else-block' on line 523-530.

Link to comment
Share on other sites

  • 2 weeks later...

I could work out a solution that works in 1.6.11.

One thing I didn't check is if the product-attributes are correct. There could be other problems, too - but it works fine for me so far!

I slightly changed my file berfore attaching (so it works with any email-template, as I use a if-clause that it works only on specific email-templates for speed reasons) - I hope I didn't make a mistake :rolleyes: . All variables used in the 'orderconf'-template should be in there now.

 

I hope you can use this file! Have fun!

Hello, dispo pour 1.6.1.11 ?

Link to comment
Share on other sites

So after two days of searching I have created a OrderHistory.php that you can place in your overrides directory that will allow you to use all of the default order_conf variables in any email template.

 

Just place the attached file in your PRESTASHOP_HOME/override/classes/order/ directory.

 

If you find any bug or mistakes in the code please let me know. Also if you have your own code that adds other variables to OrderHistory.php, then please merge with this one and post in this thread, Im sure it will be useful for other people.

 

List of variables that are added for use with this file:

 

{lastname}

{firstname}

{id_order}

{order_name}

{delivery_block_txt}

{invoice_block_txt}

{delivery_block_html}

{invoice_block_html}

{delivery_company}

{delivery_firstname}

{delivery_lastname}

{delivery_address1}

{delivery_address2}

{delivery_city}

{delivery_postal_code}

{delivery_country}

{delivery_state}

{delivery_phone}

{delivery_other}

{invoice_company}

{invoice_vat_number}

{invoice_firstname}

{invoice_lastname}

{invoice_address2}

{invoice_address1}

{invoice_city}

{invoice_postal_code}

{invoice_country}

{invoice_state}

{invoice_phone}

{invoice_other}

{order_name}

{date}

{carrier}

{payment}

{products}

{total_paid}

{total_products}

{total_discounts}

{total_shipping}

{total_wrapping}

{total_tax_paid}

 

This is tested and working on 1.6.0.14. Any other versions you can try on your own.

The file does not work on the 1.6.1.11, anyone have a solution?

Link to comment
Share on other sites

I didn't start the thread. So for 1.6.11 use the file I posted on

09 March 2017 - 02:29 PM

and read my two posts.

 

This file will work in 1.6.11!

Well I installed the file in the ovride, but this does not work, emails are not sent

Link to comment
Share on other sites

I didn't start the thread. So for 1.6.11 use the file I posted on

09 March 2017 - 02:29 PM

and read my two posts.

 

This file will work in 1.6.11!

The send mail button (from a command) does not work. So I can not test this file. Have you updated it?

Link to comment
Share on other sites

This is strange... it works perfectly on my installation of 1.6.11

Has anybody else here tested the file?

It is the button of send back(dismiss) of e-mail which does not work any more (in the commands(orders)). The file does not work with this problem. Prestashop 1.6.1.11

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...
  • 1 month later...

Hi,

 

This looks like a great tool for adding variables ! 

 

Can we use these variables in the Invoice PDF as well ? The variables in the PDF look different than these.

 

I would like to add the "Tax Name" like UK VAT from the Taxes List.

 

Also, i would like to add "Total Tax Amount" for each row in the products tab. Currently it only shows Tax Label as the Tax%.

 

 

Please help. i am on  PS 1.6.1.0

 

Thanks !

 

- Anand

Link to comment
Share on other sites

Hy,
 
I manage to make it to work for 1.6.1.11 and 1.6.1.15
 
Just download the OrderHistory.php and upload it to:
 

/prestashop_folder/override/classes/order/

Then go to:

/prestashop_folder/cache/

and delete:
 

class_index.php

 
After this you will be able to use all the order_conf variable ( the ones posted on the first post )
 

 
OrderHistory.php
 
 

This is strange... it works perfectly on my installation of 1.6.11
Has anybody else here tested the file?


Yes I test it but it was not working since you have added some custom code not related to the propose.
The email was send only if the status of the order was waiting bank wire and you also have commented a few more lines

Edited by Ionut Ac (see edit history)
  • Like 3
  • Thanks 1
Link to comment
Share on other sites

  • 2 weeks later...

Hello,

I'm using Prestashop 1.6.1.13 and cant get his to work. I want to display price for shiping excl. tax.

 

                        '{total_shipping_tax_excl}' => Tools::displayPrice($order->total_shipping_tax_excl, $this->context->currency, false),

Is not working, any idea what i should do?

Link to comment
Share on other sites

  • 5 weeks later...

Greetings,
 
I am using PS1.6.1.16 and I have developed a proper override for OrderHistory.php for this topic purpose. This override should be able you to use variables that you see in customer confirmation email (not all, see below why).
 
This override will not work with PS1.6.0 as it is not using the sendEmail function, rather it is using addWithemail function. You can change the function name to this and try.
 
Put this code into override/classes/order/OrderHistory.php. If you already have a file, simply copy the function "public function sendEmail" { }  and paste into your existing php.

<?php

class OrderHistory extends OrderHistoryCore
{	
	public function sendEmail($order, $template_vars = false)
    {
		
		$invoice = new Address((int)$order->id_address_invoice);
		$delivery = new Address((int)$order->id_address_delivery);
		$delivery_state = $delivery->id_state ? new State((int)$delivery->id_state) : false;
		$invoice_state = $invoice->id_state ? new State((int)$invoice->id_state) : false;
		$carrier = new Carrier((int)$order->id_carrier);
		
		$data = array(
				'{delivery_block_txt}' => AddressFormat::generateAddress($delivery, array('avoid' => array()), "\n", ' '),
				'{invoice_block_txt}' => AddressFormat::generateAddress($invoice, array('avoid' => array()), "\n", ' '),	
				'{delivery_block_html}' => AddressFormat::generateAddress($delivery, array('avoid' => array()), '<br />', ' ', array(
						'firstname'	=> '<span style="font-weight:bold;">%s</span>',
						'lastname'	=> '<span style="font-weight:bold;">%s</span>'
				)),
				'{invoice_block_html}' => AddressFormat::generateAddress($invoice, array('avoid' => array()), '<br />', ' ', array(
						'firstname'	=> '<span style="font-weight:bold;">%s</span>',
						'lastname'	=> '<span style="font-weight:bold;">%s</span>'
				)),
				'{delivery_company}' => $delivery->company,
				'{delivery_firstname}' => $delivery->firstname,
				'{delivery_lastname}' => $delivery->lastname,
				'{delivery_address1}' => $delivery->address1,
				'{delivery_address2}' => $delivery->address2,
				'{delivery_city}' => $delivery->city,
				'{delivery_postal_code}' => $delivery->postcode,
				'{delivery_country}' => $delivery->country,
				'{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',
				'{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,
				'{delivery_other}' => $delivery->other,
				'{invoice_company}' => $invoice->company,
				'{invoice_vat_number}' => $invoice->vat_number,
				'{invoice_firstname}' => $invoice->firstname,
				'{invoice_lastname}' => $invoice->lastname,
				'{invoice_address2}' => $invoice->address2,
				'{invoice_address1}' => $invoice->address1,
				'{invoice_city}' => $invoice->city,
				'{invoice_postal_code}' => $invoice->postcode,
				'{invoice_country}' => $invoice->country,
				'{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',
				'{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,
				'{invoice_other}' => $invoice->other,
				'{order_name}' => $order->getUniqReference(),
				'{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1),
				'{carrier}' => $carrier->name,
				'{payment}' => Tools::substr($order->payment, 0, 32),
				'{shipping_number}' => $order->shipping_number,
				//'{products}' => $product_list_html,
				//'{products_txt}' => $product_list_txt,
				//'{discounts}' => $cart_rules_list_html,
				//'{discounts_txt}' => $cart_rules_list_txt,
				'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
				'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
				'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
				'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
				'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
				'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false)

            );
			
		if ($template_vars) {
                $data = array_merge($data, $template_vars);
            }
			
		return parent::sendEmail($order, $data);
	}
}

For variable {products}, {discounts} will not work because I have not figure out the proper way to grab the values, as I am not using this variable for my other email templates.
 
Usable variables:
 
{delivery_block_txt}
{invoice_block_txt}
{delivery_block_html}
{invoice_block_html}
{delivery_company}
{delivery_firstname}
{delivery_lastname}
{delivery_address1}
{delivery_address2}
{delivery_city}
{delivery_postal_code}
{delivery_country}
{delivery_state}
{delivery_phone}
{delivery_other}
{invoice_company}
{invoice_vat_number}
{invoice_firstname}
{invoice_lastname}
{invoice_address2}
{invoice_address1}
{invoice_city}
{invoice_postal_code}
{invoice_country}
{invoice_state}
{invoice_phone}
{invoice_other}
{order_name}
{date}
{carrier}
{payment}
{shipping_number}
{total_paid}
{total_products}
{total_discounts}
{total_shipping}
{total_wrapping}
{total_tax_paid}
 

Hello,
I'm using Prestashop 1.6.1.13 and cant get his to work. I want to display price for shiping excl. tax.
 
                        '{total_shipping_tax_excl}' => Tools::displayPrice($order->total_shipping_tax_excl, $this->context->currency, false),
Is not working, any idea what i should do?


The variable that you want to add should be working using this override code. Add it in between the lines. Make sure the last variable does not have a comma.
 

'{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false),
'{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false),
'{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false),
'{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false),
'{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false),
'{total_shipping_tax_excl}' => Tools::displayPrice($order->total_shipping_tax_excl, $this->context->currency, false),
'{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false)

  • Like 1
Link to comment
Share on other sites

Can You provide an override version of this file? I assume that is only public function addWithemail is changed so we don't need to override all class. Am I right?

 

Override sendEmail for PS1.6.1

Override addWithemail for PS1.6.0

 

See my override code above.

Link to comment
Share on other sites

  • 4 weeks later...

Hello,

 

thank you for providing a solution for us to use order_conf variables in any email template because I realy need to implement this in my shop.

 

Still I can't seem to make it work in my 1.6.1 version. I might be missing something but I don't see what.

 

The actions I did :

 

- Copying Sandrayin code into a php file named OrderHistory.php and placing it into override/classes/order.

- Creating the mail template I need with the variables {date} / {carrier} / {items} / {total_discounts} / {total_shipping} / {total_taxe_paid} and many more.

- Setting this email template for when the state change in the BO.

 

Doing test orders to try the status, the mail are not taking the variables ( they are shown has in the template, ie "{total_shipping}").

 

Do you have any idea what I can do to troubleshot and fix this to have the intended behaviour ? 

Link to comment
Share on other sites

Hello,

 

thank you for providing a solution for us to use order_conf variables in any email template because I realy need to implement this in my shop.

 

Still I can't seem to make it work in my 1.6.1 version. I might be missing something but I don't see what.

 

The actions I did :

 

- Copying Sandrayin code into a php file named OrderHistory.php and placing it into override/classes/order.

- Creating the mail template I need with the variables {date} / {carrier} / {items} / {total_discounts} / {total_shipping} / {total_taxe_paid} and many more.

- Setting this email template for when the state change in the BO.

 

Doing test orders to try the status, the mail are not taking the variables ( they are shown has in the template, ie "{total_shipping}").

 

Do you have any idea what I can do to troubleshot and fix this to have the intended behaviour ? 

 

Follow my instruction and it will work:

https://www.prestashop.com/forums/topic/465115-solution-how-to-use-order-conf-variables-in-any-email-template/?p=2583804

 

Just download the file and follow the instructions.

Link to comment
Share on other sites

Hi

I would like to take our internal reference number and add it to the mailalert as a Barcode.

I can insert into PDF invoice, with this code by haylau
 

<tr>
<td style="width: 17%"></td>
<td style="width: 83%">
 
{assign var=black value=[0,0,0]}{assign var=white value=[255,255,255]}
{assign var=stuff value=['position'=>'S', 'border'=>false, 'padding'=>4, 'fgcolor'=>$black, 'bgcolor'=>$white, 'text'=>false, 'font'=>'helvetica', 'fontsize'=>8, 'stretchtext'=>4]}
{assign var=params value=TCPDF::serializeTCPDFtagParameters(array($order->getUniqReference(), 'C39', '', '', 40, 15, 0.4, $stuff, 'N'))}
<tcpdf method="write1DBarcode" params="{$params}" />
 
</td>
</tr>

 
 
but i'd like to insert inside order confirmation mails.
thanks

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 6 months later...
  • 3 months later...
  • 3 months later...
  • 4 weeks later...
On 7/13/2017 at 9:45 PM, Ionut Ac said:

Hy,
 
I manage to make it to work for 1.6.1.11 and 1.6.1.15
 
Just download the OrderHistory.php and upload it to:
 


/prestashop_folder/override/classes/order/

Then go to:


/prestashop_folder/cache/

and delete:
 


class_index.php

 
After this you will be able to use all the order_conf variable ( the ones posted on the first post )
 

 
OrderHistory.php
 
 

 

Yes I test it but it was not working since you have added some custom code not related to the propose.
The email was send only if the status of the order was waiting bank wire and you also have commented a few more lines

Hello, it works for me. Thanks so much.

Link to comment
Share on other sites

  • 3 weeks later...
On 10/24/2018 at 1:08 PM, laurentm44 said:

I'm very interested in the version for PS 1.7 too 

 

On 2/6/2019 at 4:18 AM, Yves said:

Me too 🤔

 

On 10/18/2018 at 3:44 PM, thehurricane said:

any solution for PS 1.7? ;)

 

On 3/7/2019 at 3:54 PM, feinkost said:

Is there any solution to provide the order data variables for all the email templates with Prestashop 1.7.5.1?

I found this solution  - https://stackoverflow.com/questions/53057852/prestashop-1-7-4-x-missing-variables-values-when-using-order-conf-as-new-email

but it not work for me (prestashop 1.7.5.1)

maybe someone found a working solution....??

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

  • 1 month later...
On 3/24/2019 at 2:53 PM, cosmoll said:

 

 

 

I found this solution  - https://stackoverflow.com/questions/53057852/prestashop-1-7-4-x-missing-variables-values-when-using-order-conf-as-new-email

but it not work for me (prestashop 1.7.5.1)

maybe someone found a working solution....??

Thank you
The solution works for me. I'm using presta 1.7.5.1
but I use my own code only to get order date_add

1. I copy OrderHistory.php to /override/classes/order
Then I add {TanggalJT} into $data array which get from $results fields

public function sendEmail($order, $template_vars = false)
    {   
        // I added query for date_add column in orders table
        $result = Db::getInstance()->getRow('
            SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`, o.`date_add` 
            FROM `' . _DB_PREFIX_ . 'order_history` oh
                LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
                LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
                LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
                LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
            WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1');
        if (isset($result['template']) && Validate::isEmail($result['email'])) {
            ShopUrl::cacheMainDomainForShop($order->id_shop);

            $topic = $result['osname'];
            $data = array(
                '{lastname}' => $result['lastname'],
                '{firstname}' => $result['firstname'],
                '{id_order}' => (int) $this->id_order,
                '{order_name}' => $order->getUniqReference(),
				'{TanggalJT}' => date('d M Y H:i:s', strtotime($result['date_add']. ' + 1 days'))  // this I use date_add column for query
            );

 

2. Then I insert {tanggalJT} to bankwire.html email template, it works

image.png.92ccfebf5e26f169b420b6fae7a45adb.png

 

 

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

  • 2 weeks later...
  • 1 month later...

Hi there,

At 1.7.3.3 it is working. I'm attaching mine OrderHirstory.php file. Basically opened the original file that i had and just inserted the new functionality developed by the author.  After that deleted /app/cache/dev/class_index.php and /app/cache/prod/class_index.php , deleted the cache and tested it with shipped.html with many variables like delivery address , produts , etc.... and all are working. Some bugs are possible since i haven't test it much.

Right now i'm looking for a solution for order_changed.html to add those variables there. I think is generated from a different place.

Thank you all for the great community that we have.
 D.

OrderHistory.php

Edited by DanielaPetkova (see edit history)
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 10 months later...

Does anybody know the solution for 1.7.6.0? All solutions described here don't work...

 

I am trzing to add a "variable" customer message {message} into order_conf email template.

Thank you

  • Like 1
Link to comment
Share on other sites

  • 4 months later...
  • 5 months later...
  • 3 weeks later...
On 7/13/2017 at 9:45 PM, Ionut Ac said:

Hy,
 
I manage to make it to work for 1.6.1.11 and 1.6.1.15
 
Just download the OrderHistory.php and upload it to:
 


/prestashop_folder/override/classes/order/

Then go to:


/prestashop_folder/cache/

and delete:
 


class_index.php

 
After this you will be able to use all the order_conf variable ( the ones posted on the first post )
 

 
OrderHistory.php
 
 

 

Yes I test it but it was not working since you have added some custom code not related to the propose.
The email was send only if the status of the order was waiting bank wire and you also have commented a few more lines

 

It works very well on PS 1.6.1.4
Thank you!

Link to comment
Share on other sites

  • 3 months later...
On 6/15/2019 at 1:29 PM, DanielaPetkova said:

Hi there,

At 1.7.3.3 it is working. I'm attaching mine OrderHirstory.php file. Basically opened the original file that i had and just inserted the new functionality developed by the author.  After that deleted /app/cache/dev/class_index.php and /app/cache/prod/class_index.php , deleted the cache and tested it with shipped.html with many variables like delivery address , produts , etc.... and all are working. Some bugs are possible since i haven't test it much.

Right now i'm looking for a solution for order_changed.html to add those variables there. I think is generated from a different place.

Thank you all for the great community that we have.
 D.

OrderHistory.php 35.65 kB · 87 downloads

Today (June 2021) it works for me on PS 1.7.7.1 thanks to your file and my modifications. I managed to perfectly display all variables in all email templates.

 

If anyone needs help, please reply to this comment.

 

@DanielaPetkova thank you very much for your file, was fundamental!! ☺️

 

:)

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

8 hours ago, markinhos3 said:

Today (June 2021) it works for me on PS 1.7.7.1 thanks to your file and my modifications. I managed to perfectly display all variables in all email templates.

 

If anyone needs help, please reply to this comment.

 

@DanielaPetkova thank you very much for your file, was fundamental!! ☺️

 

:)

Could you briefly step-by-step write here what namely was made and changed for 1.7.7.1 by you? Maybe attach also readymade files? Thank you!

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

On 6/29/2021 at 4:48 PM, way1 said:

Could you briefly step-by-step write here what namely was made and changed for 1.7.7.1 by you? Maybe attach also readymade files? Thank you!

Hello way1, I have version 1.7.7.4, what I did was:

1 - Create an override of the OrderHistory.php file in override / classes / order

2 - Then in the sendEmail function, add the variable, both in the SQL query and in the $data array.

I show you an example of what I did to be able to show the customer ID in the mail. (added variable $ id_customer)

 

 public function sendEmail($order, $template_vars = false)
    {
        $result = Db::getInstance()->getRow('
            SELECT osl.`template`, c.`lastname`, c.`firstname`, c.`id_customer`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`
            FROM `' . _DB_PREFIX_ . 'order_history` oh
                LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
                LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
                LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
                LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
            WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1');
        if (isset($result['template']) && Validate::isEmail($result['email'])) {
            ShopUrl::cacheMainDomainForShop($order->id_shop);

            $topic = $result['osname'];
            $carrierUrl = '';
            if (Validate::isLoadedObject($carrier = new Carrier((int) $order->id_carrier, $order->id_lang))) {
                $carrierUrl = $carrier->url;
            }
            $data = [
                '{id_customer}' => $result['id_customer'],
                '{lastname}' => $result['lastname'],
                '{firstname}' => $result['firstname'],
                '{id_order}' => (int) $this->id_order,
                '{order_name}' => $order->getUniqReference(),
                '{followup}' => str_replace('@', $order->getWsShippingNumber(), $carrierUrl),
                '{shipping_number}' => $order->getWsShippingNumber(),
            ];

 

  • Like 2
Link to comment
Share on other sites

  • 1 year later...

Hello

Any solution for 1.7.8?

On 7/7/2021 at 5:52 PM, Facundo13 said:

Hello way1, I have version 1.7.7.4, what I did was:

1 - Create an override of the OrderHistory.php file in override / classes / order

2 - Then in the sendEmail function, add the variable, both in the SQL query and in the $data array.

I show you an example of what I did to be able to show the customer ID in the mail. (added variable $ id_customer)

 

 public function sendEmail($order, $template_vars = false)
    {
        $result = Db::getInstance()->getRow('
            SELECT osl.`template`, c.`lastname`, c.`firstname`, c.`id_customer`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`
            FROM `' . _DB_PREFIX_ . 'order_history` oh
                LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
                LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
                LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
                LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
            WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1');
        if (isset($result['template']) && Validate::isEmail($result['email'])) {
            ShopUrl::cacheMainDomainForShop($order->id_shop);

            $topic = $result['osname'];
            $carrierUrl = '';
            if (Validate::isLoadedObject($carrier = new Carrier((int) $order->id_carrier, $order->id_lang))) {
                $carrierUrl = $carrier->url;
            }
            $data = [
                '{id_customer}' => $result['id_customer'],
                '{lastname}' => $result['lastname'],
                '{firstname}' => $result['firstname'],
                '{id_order}' => (int) $this->id_order,
                '{order_name}' => $order->getUniqReference(),
                '{followup}' => str_replace('@', $order->getWsShippingNumber(), $carrierUrl),
                '{shipping_number}' => $order->getWsShippingNumber(),
            ];

 

Hello

Already create the Orderhistory.php overide

Can you point where is the sendemail function? I would like to send email with products that customer bought with a link

I have {products} in modern theme, but is not showing nothing :(

PS 1.7.8

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

On 11/16/2022 at 2:42 PM, Borgas said:

Hello

Any solution for 1.7.8?

Hello

Already create the Orderhistory.php overide

Can you point where is the sendemail function? I would like to send email with products that customer bought with a link

I have {products} in modern theme, but is not showing nothing :(

PS 1.7.8

Hi,

I have managed to solve it for ps 1.7.8, I do not know if it will work for all cases, at least in mine if (I use the warehouse template).

In my template the files were missing: order_conf_product_list.tpl and order_conf_product_list.txt, they were in the ps folder /mails/_partials and I copied them to /themes/warehouse/mails/es/ and it worked.

I hope this solution works for someone, at least it worked perfectly for me.

Link to comment
Share on other sites

19 minutes ago, pShark said:

Hi,

I have managed to solve it for ps 1.7.8, I do not know if it will work for all cases, at least in mine if (I use the warehouse template).

In my template the files were missing: order_conf_product_list.tpl and order_conf_product_list.txt, they were in the ps folder /mails/_partials and I copied them to /themes/warehouse/mails/es/ and it worked.

I hope this solution works for someone, at least it worked perfectly for me.

Works like a charm

 

Just copy mails/_partials to YOURTHEME/MAILS/LANGUAGES

Edit as you wich

Link to comment
Share on other sites

  • 7 months later...
Am 22.11.2022 um 1:35 PM schrieb pShark:

Hi,

I have managed to solve it for ps 1.7.8, I do not know if it will work for all cases, at least in mine if (I use the warehouse template).

In my template the files were missing: order_conf_product_list.tpl and order_conf_product_list.txt, they were in the ps folder /mails/_partials and I copied them to /themes/warehouse/mails/es/ and it worked.

I hope this solution works for someone, at least it worked perfectly for me.

Hi! It works for 1.7.6.9 too. Thanks 🙂 But the files are in /mails/en folder in my case 😉 

Link to comment
Share on other sites

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...