sebastian LiteCart Fan Từ United States Thành viên kể từ thg 1 2022 sebastian 6 thg 1 2022 21:27 Hello By default, Litecart generates a simple text email like below: What is the easiest way to convert that into html table with formatting? I already know that html must be enabled inside the ent_orders.inc.php under "public function email_order_copy()" function [->add_body($message,true)] and also inside translations. I have come up with a way to do that but not sure if it's the right way to do it. See the desired format attached. I know that Litecart provides a printable form but I think it would be nice to send a more sophisticated email like the desired format below. Default email: [quote]Thank you for your purchase! Your order #2 has successfully been created with a total of $30 for the following ordered items: 1 x Black T-shirt (slim) A printable order copy is available here: https://mystore.com/order?order_id=2&public_key=uam7ohfnofg2f10e0uiirtup8ml1k731 Regards, My store https://mystore.com[/quote] Here is how I edited translations and ent_order.inc.php under email_order_copy() function. This template is from HTMLemail and is supposed to work in most browsers and email clients. translations->email_order_confirmation: <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Your order confirmation</title> </head> <body class="" style="background-color: #f6f6f6; font-family: sans-serif; -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.4; margin: 0; padding: 0; -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;"> <span class="preheader" style="color: transparent; display: none; height: 0; max-height: 0; max-width: 0; opacity: 0; overflow: hidden; mso-hide: all; visibility: hidden; width: 0;"></span> <table role="presentation" border="0" cellpadding="0" cellspacing="0" class="body" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f6f6f6; width: 100%;" width="100%" bgcolor="#f6f6f6"> <tr> <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top"> </td> <td class="container" style="font-family: sans-serif; font-size: 14px; vertical-align: top; display: block; max-width: 580px; padding: 10px; width: 580px; margin: 0 auto;" width="580" valign="top"> <div class="content" style="box-sizing: border-box; display: block; margin: 0 auto; max-width: 580px; padding: 10px;"> <!-- START CENTERED WHITE CONTAINER --> <table role="presentation" class="main" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background: #ffffff; border-radius: 3px; width: 100%;" width="100%"> <!-- START MAIN CONTENT AREA --> <tr> <td class="wrapper" style="font-family: sans-serif; font-size: 14px; vertical-align: top; box-sizing: border-box; padding: 20px;" valign="top"> <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%"> <tr> <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top"> <p> <h1 style="color:#494949;direction:ltr;font-family:sans-serif;font-size:40px;font-weight:bold;letter-spacing:normal;line-height:120%;text-align:center;margin-top:0;margin-bottom:0;"><strong><span style="color: #05629b;">P</span><span><span style="color: #4bb33f;"><span style="color: #e06310;">o</span>merix </span></span></strong></h1> </p> <p style="font-family: sans-serif; font-size: 20px; font-weight: normal; margin: 0; margin-bottom: 15px;">Thanks for your purchase!</p> <p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">Your order #%order_id has successfully been created with a total of %payment_due for the following ordered items:</p> %order_items <table role="presentation" border="0" cellpadding="0" cellspacing="0" class="btn btn-primary" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; box-sizing: border-box; width: 100%;" width="100%"> <tbody> <tr> <td align="left" style="font-family: sans-serif; font-size: 14px; vertical-align: top; padding-bottom: 15px;" valign="top"> <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: auto;"> <tbody> <tr> <td style="font-family: sans-serif; font-size: 14px; vertical-align: top; border-radius: 5px; text-align: center; background-color: #3498db;" valign="top" align="center" bgcolor="#3498db"> <a href="%order_copy_url" target="_blank" style="border: solid 1px #3498db; border-radius: 5px; box-sizing: border-box; cursor: pointer; display: inline-block; font-size: 14px; font-weight: bold; margin: 0; padding: 12px 25px; text-decoration: none; text-transform: capitalize; background-color: #3498db; border-color: #3498db; color: #ffffff;">Download invoice</a> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">Please let us know if you have any questions or comments.</p> <p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">mystore </p> </td> </tr> </table> </td> </tr> <!-- END MAIN CONTENT AREA --> </table> <!-- END CENTERED WHITE CONTAINER --> <!-- START FOOTER --> <div class="footer" style="clear: both; margin-top: 10px; text-align: center; width: 100%;"> <table role="presentation" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;" width="100%"> <tr> <td class="content-block" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; color: #999999; font-size: 12px; text-align: center;" valign="top" align="center"> <span class="apple-link" style="color: #999999; font-size: 12px; text-align: center;">mystore , 411 E. Huntington Dr. #107-309, Arcadia, CA 91006</span> </td> </tr> <tr> <td class="content-block powered-by" style="font-family: sans-serif; vertical-align: top; padding-bottom: 10px; padding-top: 10px; color: #999999; font-size: 12px; text-align: center;" valign="top" align="center"> Powered by <a href="http://htmlemail.io" style="color: #999999; font-size: 12px; text-align: center; text-decoration: none;">HTMLemail</a>. </td> </tr> </table> </div> <!-- END FOOTER --> </div> </td> <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top"> </td> </tr> </table> </body> </html>``` ent_order.inc.php under email_order_copy() function: ```$item_counter=1; $grandtotal=0; foreach ($this->data['items'] as $item) { if (!empty($item['product_id'])) { if ($item_counter==1) { $aliases['%order_items'] .='<table border="0" align="center"><tr style="text-align: center;background-color:lightgrey"><th>Quantity</th><th>Item</th><th>Price</th></tr>'; } $product = reference::product($item['product_id'], $language_code); $options = []; $row_price=(float)$item['price']*$item['quantity']; if (!empty($item['options'])) { foreach ($item['options'] as $k => $v) { $options[] = $k .': '. $v; } } $aliases['%order_items'] .= '<tr style="text-align: center;"><td>'.(float)$item['quantity'] .'</td><td>'. $product->name . (!empty($options) ? ' ('. implode(', ', $options) .')' : '') . "<br />\r\n</td><td>$".$row_price."</td></tr>"; } else { $aliases['%order_items'] .= '<tr style="text-align: center;"><td>Hello'.(float)$item['quantity'] . '</td><td>'. $item['name'] . (!empty($options) ? ' ('. implode(', ', $options) .')' : '') . "<br />\r\n'</td><td>$".$row_price."</td></tr>'."; } $subtotal += $row_price; $item_counter++; } $grandtotal=$subtotal+$this->data['tax_total']; $aliases['%order_items'] .='<tr style="text-align: center;"><td></td><td align="center"><b>Subtotal</b></td><td><b>$'.$subtotal.'</b></td></tr> <tr style="text-align: center;"><td></td><td align="center"><b>Tax</b></td><td ><b>$'.$this->data['tax_total'].'</b></td></tr> <tr style="text-align: center;"><td></td><td align="center"><b>Grand total</b></td><td ><b>$'.$grandtotal.'</b></td></tr> </table>'; $aliases['%order_items'] = trim($aliases['%order_items']);```
tim Founder Từ Sweden Thành viên kể từ thg 5 2013 tim 8 thg 1 2022 06:03 Your grand total will not include shipping fees or discount from the order total rows. Try this instead of a translation: currency::format($this->data['payment_due'], true, $this->data['currency_code'], $this->data['currency_value']) I would throw this into a view instead of a translation. language::set($this->data['language_code']); $_view = new ent_view(); $_view->snippets = [ ... your aliases here ... ]; $message = $_view->stitch('email/order_copy'); language::set($session_language); // Revert language``` https://wiki.litecart.net/how_to_create_a_box
sebastian LiteCart Fan Từ United States Thành viên kể từ thg 1 2022 sebastian 8 thg 1 2022 18:05 Thank you Tim for your response. I need to educate myself on how to add/edit views and boxes.
tim Founder Từ Sweden Thành viên kể từ thg 5 2013 tim 8 thg 1 2022 22:28 Views sounds soo complex but they are soo simple :) There is also a simple example here: https://wiki.litecart.net/how_to_create_a_page