Jump to content

Adding extra info to order confirmation email


Recommended Posts

I want to add more stuff to the order confirmation email (new order email), so I dont need to acces every time an order comes the back-end of the webshop.

So, I would like to add some data like:
- mobile phone number
- the group in which the user is
- other informations provided under by the user

does anyone know a solution to add this datas in that email?

Thank you very much.

Link to comment
Share on other sites

To add the mobile phone numbers to the "New order" email, you'll need to modify the "// Filling-in vars for email" section on line 130 of modules/mailalerts/mailalerts.php and add the following to the $templateVars array:

'{delivery_mobile}' => $delivery->phone_mobile,
'{invoice_mobile}' => $invoice->phone_mobile,



To put the customer group in the email is not so easy, since customers can be in multiple groups and you can't use foreach loops in the email templates. The best you can do is to get the last customer group. For example:

$groups = $customer->getGroups();



then add the following to the $templateVars array:

'{customer_group}' => $groups[sizeof($groups) - 1],

  • Like 1
Link to comment
Share on other sites

Thank you very much rocky.

Since I have only two groups, for now it's good this solution too.

If you have more ideas of adding data in the new order email you could (please) add them in this topic to have them together.

Link to comment
Share on other sites

Actually, now that I think about it, you could get all the customer groups by using the following code:

$groups = $customer->getGroups();
$customer_groups = '';
foreach ($groups as $group)
   $customer_groups .= ($customer_groups != '' ? ', ' : '') . $group;



then:

'{customer_groups}' => $customer_groups,

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Rocky,

I would like to add EAN13, unit price (excl tax), tax, total price (unit price + tax) as well as total tax, total price (excl tax) and Grand Total (Total price + total tax). How can I achieve this?

I am working on a wholesale website and all detailed tax information is required in the new order email.

Thanks

Link to comment
Share on other sites

It's easy to do. You'll need to modify a lot of code.

For example, to add the EAN13, you will need to edit classes/PaymentModule.php and change lines 225 and 236 (in PrestaShop v1.3.1) from:

'.$product['reference'].'



to:

'.$product['reference'].'
'.$product['ean13].'



then change lines 35-39 of order_conf.html in your mails directory from:

Reference
Product
Unit price
Quantity
Total price



to:

Reference
EAN13
Product
Unit price
Quantity
Total price



For the total, you will need to add a new entry in the $data array on line 308 like the following:

'{grand_total}' => $order->total_paid_real,



Then add {grand_total} to order_conf.html and order_conf.txt where you want it to be displayed.

Hopefully, this will guide you in the right direction.

  • Like 1
Link to comment
Share on other sites

Hi Rocky,

Thanks for you quick reply. I have made the changes. EAN13 title is inserted but the actual product ean13 is not inserted.

I assume the barcode should be inserted by this code in PaymentModule.php


'.$product['ean13'].'




Do you know what else I should do to diaply the barcodes?

Thanks

Link to comment
Share on other sites

Rocky,

I have figured out how to insert ean13 by modifying mailalerts.php. I am mainly concerned with new order alert. Thank you for your help on this.

I have another question. In the new order email or invoice I want to display both unit price and total prices without tax, and display total tax separately. How can I achieve this?

What I want to display:

EAN13 Product Name Unit Price (excl tax) Quantity Total Price (excl tax)

Net Total
Total Tax
Grand Total

Link to comment
Share on other sites

I'm not sure why it isn't working. It is the following on line 228 that is part of the query that gets the EAN13:

IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13, pai.`id_image` AS \'pai_id_image\'



I suggest that you add the following on line 255 after the query:

echo $sql;



This will display the query that is being executed. Copy it and try running it using phpMyAdmin to see whether the EAN13 is included in the results.

Link to comment
Share on other sites

  • 1 month later...

Hello ,
I used EAN13 too in my new order email and changed the code some time ago: the updates to the code are similair to what Rocky wrote above.
But I went over too : I managed to add a new flag in order to be able to send a different notification email to the depot (that will pick the products and then ship them).

Now I want to add more fields to this new email (ean13 has been already added): I want to add a field for the size of the product (or box).
I was thinking of using a feature field to store the SIZE of the product/box.
Any suggestion?
Is using a feature is ok, then how can I retrieve the value in the mailalert.php ? Is there a function ? Or do I have to modify the query ?

Thanks

Link to comment
Share on other sites

  • 1 year later...

This is how I added mobile phones to new order mail on PS 1.4.7.3

 

Edit: /modules/mailalerts/mails / your language / new_order.html

 

Added this after {delivery_block_html}:

 

 

{delivery_phone_mobile}

{delivery_phone}

 

Added this after {invoice_block_html}:

 

{invoice_phone_mobile}

{invoice_phone}

 

Edit /modules/mailalerts/mailalerts.php

 

Added this after '{delivery_phone}' => $delivery->phone, :

'{delivery_phone_mobile}' => $delivery->phone_mobile,

 

And this after '{invoice_phone}' => $invoice->phone, :

'{invoice_phone_mobile}' => $invoice->phone_mobile,

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hello guys. Thank you for sharing your solutions. I'd like to add the description and the short description next to the product name in the New Order email generated by mailalerts. I have several products with the same name so I can't distuinguish them when I receive an order. Can anyone help with this? I'd really appreciate it. Thank you for your time.

 

Best regards,

Dylan

Link to comment
Share on other sites

  • 3 months later...

It's easy to do. You'll need to modify a lot of code.

 

For example, to add the EAN13, you will need to edit classes/PaymentModule.php and change lines 225 and 236 (in PrestaShop v1.3.1) from:

 

'.$product['reference'].'

 

to:

 

'.$product['reference'].'
'.$product['ean13].'

 

then change lines 35-39 of order_conf.html in your mails directory from:

 

Reference
Product
Unit price
Quantity
Total price

 

to:

 

Reference
EAN13
Product
Unit price
Quantity
Total price

 

For the total, you will need to add a new entry in the $data array on line 308 like the following:

 

'{grand_total}' => $order->total_paid_real,

 

Then add {grand_total} to order_conf.html and order_conf.txt where you want it to be displayed.

 

Hopefully, this will guide you in the right direction.

 

Ey rocky this post is a lot of help!! :)

 

But is a little older... in 1.5.3.1 in classes/PaymentModule.php there is no

'.$product['reference'].'

in that lines... i think is in the 381... between <td..."???

 

And the important question... i have a "feature" in each product named acslink... how i send that data from paymentmodule to paymentconfirmation email??? :)

 

A LOT of thanks!

 

 

By the other hand... in classes/PaymentModule.php i see styles and html coding... ¿is that correct MCV? lines 380-

386...

'<tr style="background-color: '.($key % 2 ? '#DDE2E6' : '#EBECEE').';">
    <td style="padding: 0.6em 0.4em;width: 15%;">'.$product['reference'].'</td>
    <td style="padding: 0.6em 0.4em;width: 30%;"><strong>'.$product['name'].(isset($product['attributes']) ? ' - '.$product['attributes'] : '').' - '.Tools::displayError('Customized').(!empty($customization_text) ? ' - '.$customization_text : '').'</strong></td>
    <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ?  Tools::ps_round($price, 2) : $price_wt, $this->context->currency, false).'</td>
    <td style="padding: 0.6em 0.4em; width: 15%;">'.$customization_quantity.'</td>
    <td style="padding: 0.6em 0.4em; width: 20%;">'.Tools::displayPrice($customization_quantity * (Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $price_wt), $this->context->currency, false).'</td>
   </tr>';

Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...
  • 1 month later...

Hi Guys,

 

Rocky you seem to be a legend on all things mail!! Im using version 1.5.4.1 and i need to add messages {messages} in to the order_conf.txt file as i print the orders directly in the restaurant as the orders come in, they have no access to BO PS. To check for messages.

 

Any help on this would be awesome.

 

Regards

 

Patrick

Link to comment
Share on other sites

  • 3 weeks later...

How do you add a VAT field to new_order.html ( new order mail to shop)?

 

I tried  '{total_tax}' => Tools::displayPrice($order->total_tax, $currency), in mailalerts.php it didnt work

 

I managed to get the Net Amount in by replacing 

'{total_products}' => Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency),

to 

'{total_products}' => Tools::displayPrice($order->getTotalProductsWithoutTaxes(), $currency),

but still cant get rid of the Total Price( with VAT added ) at the top

 

Please...

 

Cheers

Julian

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

 

To put the customer group in the email is not so easy, since customers can be in multiple groups and you can't use foreach loops in the email templates. The best you can do is to get the last customer group. For example:

 

$groups = $customer->getGroups();

 

Sorry to retrieve such old post, but where do i add this?

Link to comment
Share on other sites

  • 1 month later...

Hello all,

i'd need some extra infos from the order confirmation mail: the Paypal status. How can i put it in the code? And is it possible?

I don't know if the status of paypal changes AFTER getting the confirmation mail or if the mail is sent after the customer pays with Paypal.

 

How can i do it? Thanks

Link to comment
Share on other sites

  • 1 year later...

Actually, now that I think about it, you could get all the customer groups by using the following code:

 

$groups = $customer->getGroups();$customer_groups = '';foreach ($groups as $group)    $customer_groups .= ($customer_groups != '' ? ', ' : '') . $group;

then:

 

'{customer_groups}' => $customer_groups,

Not work in Prestashop 1.6.0.9

Any idea?

Thanks

Link to comment
Share on other sites

  • 2 months later...
  • 8 months later...

Hello guys. Thank you for sharing your solutions. I'd like to add the description and the short description next to the product name in the New Order email generated by mailalerts. I have several products with the same name so I can't distuinguish them when I receive an order. Can anyone help with this? I'd really appreciate it. Thank you for your time.

 

Best regards,

Dylan

 

Hi,

 

Didi you find a clean solution for adding  description and the short description next to the product name in email?

I am PS 1.6.14, I could not find a clear way to insert additional product information in status emails.

 

V.

Link to comment
Share on other sites

  • 3 months later...

Hi,

 

Didi you find a clean solution for adding  description and the short description next to the product name in email?

I am PS 1.6.14, I could not find a clear way to insert additional product information in status emails.

 

V.

 

Hello,

 

I'm also interested in the solution to add additionnal information to mails, which seems to be sent by the Mail Alert module, for prestashop 1.6.

 

K

Link to comment
Share on other sites

  • 3 years later...

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