Post by febelam » Thu Apr 26, 2012 6:47 pm

Hi All,

i am using opencart 1.5.2.1, how can i add product description under the product name in the order confirmation email?
What code i have to add? What file i need to edit?
please help~~~

Febe

Newbie

Posts

Joined
Thu Apr 26, 2012 6:42 pm

Post by Avvici » Tue May 01, 2012 8:53 pm

Sorry for the delay in response. Sometimes they fall through the cracks:)
Open this file: catalog/model/checkout/order.php
Find this line:

Code: Select all

$template->data['products'][] = array(
					'name'     => $product['name'],
					'model'    => $product['model'],
					'option'   => $option_data,
					'quantity' => $product['quantity'],
					'price'    => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']),
					'total'    => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value'])
				);
Make it look like this:

Code: Select all

 $order_product_description_query = $this->db->query("SELECT description FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product['id'] . "'");
				$description = html_entity_decode($order_product_description_query->row['description'], ENT_QUOTES, 'UTF-8');
				
				$template->data['products'][] = array(
					'name'     => $product['name'],
					'description'     => $description,
					'model'    => $product['model'],
					'option'   => $option_data,
					'quantity' => $product['quantity'],
					'price'    => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']),
					'total'    => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value'])
				);
So, all we did was grab the product description while inside the existing foreach loop, and added it to the array.
Now open up: catalog/view/theme/default/template/mail/order.tpl
Find this line:

Code: Select all

  <td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; background-color: #EFEFEF; font-weight: bold; text-align: left; padding: 7px; color: #222222;"><?php echo $text_product; ?></td>
After that put this:

Code: Select all

  <td style="font-size: 12px; border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; background-color: #EFEFEF; font-weight: bold; text-align: left; padding: 7px; color: #222222;"><?php echo "Description"; ?></td>
Now find this:

Code: Select all

 <td style="font-size: 12px;	border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;"><?php echo $product['name']; ?>
          <?php foreach ($product['option'] as $option) { ?>
          <br />
          &nbsp;<small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
          <?php } ?></td>
And add this below it:

Code: Select all

<td style="font-size: 12px;	border-right: 1px solid #DDDDDD; border-bottom: 1px solid #DDDDDD; text-align: left; padding: 7px;"><?php echo $product['description']; ?></td>
NOTE: You might run into spacing issues because descriptions can be long. If this is the case then you will want to re-structure your Mail Template to make it fit properly.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by febelam » Wed May 02, 2012 12:40 pm

hi avvici, i have following all the steps, but it is not working, nothing appear on the description column. please help! Also what code i have to add if i have 2 languages for the description?
thank you!

Attachments

mail.jpg

mail.jpg (222.55 KiB) Viewed 4603 times


Newbie

Posts

Joined
Thu Apr 26, 2012 6:42 pm

Post by morriskoon » Wed May 02, 2012 4:06 pm

hi, i'm working with febelam, all code is fine, but the query line:
$order_product_description_query = $this->db->query("SELECT description FROM " . DB_PREFIX . "product_description WHERE product_id = '" . (int)$product['id'] . "'");

the col name should be $product['product_id'],
thanks alot.

Newbie

Posts

Joined
Mon Apr 30, 2012 4:45 pm

Post by Avvici » Wed May 02, 2012 7:31 pm

Febelam, like he said just make the variable $product['product_id'] instead of $product['id']. I normally don't test my code before suggesting it so thanks for catching that.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by robster » Wed Sep 12, 2012 9:55 pm

Is there also a way to add the total weight to the order confirmation email?

Thanks

robster

I know my place...!


User avatar
Active Member

Posts

Joined
Tue Jul 13, 2010 8:08 pm
Location - North Yorkshire, UK
Who is online

Users browsing this forum: No registered users and 67 guests