pastik Posted March 8, 2010 Share Posted March 8, 2010 Hi,when I placed order in my shop, i received the confirmation email about that. I can see the product name, but how can I add product ID to email template ? Any ideas ?thx. Link to comment Share on other sites More sharing options...
gonandriy Posted March 10, 2010 Share Posted March 10, 2010 You probably can't do that through admin GUI. You need find where prestashop send email (class Mail may be) and add product.id into email template. First of all product_id is included as the component of products list item structure, so you need not care about fetch this from database, just insert it into required place of template body Link to comment Share on other sites More sharing options...
pastik Posted March 10, 2010 Author Share Posted March 10, 2010 Thanks for reply, I tried to modify my particular template, I added #{id_product}, but it doesn't work. Something is missing, but don't know where. Link to comment Share on other sites More sharing options...
rocky Posted March 11, 2010 Share Posted March 11, 2010 You'll need to change the following code in modules/mailalerts/mailalerts.php on line 106: $itemsTable .= ' '.$product['reference'].' '.$product['name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').' '.Tools::displayPrice($unit_price, $currency, false, false).' '.intval($product['quantity']).' '.Tools::displayPrice(($price * $product['quantity']), $currency, false, false).' '; Change it to something like: $itemsTable .= ' '.$product['id_product'].' '.$product['reference'].' '.$product['name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').' '.Tools::displayPrice($unit_price, $currency, false, false).' '.intval($product['quantity']).' '.Tools::displayPrice(($price * $product['quantity']), $currency, false, false).' '; You'll need to modify modules/mailalerts/mails/en/new_order.html to add a header for the new column. Change lines 34-38 from: Reference Product Unit price Quantity Total price to something like: ID Reference Product Unit price Quantity Total price Link to comment Share on other sites More sharing options...
dramony Posted October 1, 2010 Share Posted October 1, 2010 what if i want to show the Category name where it is from? can i use $product['category']? Link to comment Share on other sites More sharing options...
rocky Posted October 1, 2010 Share Posted October 1, 2010 No, it's not that easy. You will need to get the category to get its name. Change line 108 of modules/mailalerts/mailalerts.php (in PrestaShop v1.3.1) from: $itemsTable .= to: $category = new Category($product['id_category_default'], $id_lang); $itemsTable .= Then you can use $category->name where you want the product category displayed. Link to comment Share on other sites More sharing options...
dramony Posted October 1, 2010 Share Posted October 1, 2010 i see 2 $itemsTable .= at line 93 and line 104here's a copy of my code from line 93 to line 116: $itemsTable .= ' '.$product['reference'].' '.$product['name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').' '.Tools::displayPrice($price * ($tax + 100) / 100, $currency, false, false).' '.intval($product['quantity']).' '.Tools::displayPrice(intval($product['quantity']) * ($price * ($tax + 100) / 100), $currency, false, false).' '; } foreach ($params['cart']->getDiscounts() AS $discount) { $itemsTable .= ' '.$this->l('Voucher code:').' '.$objDiscount->name.' -'.Tools::displayPrice($value, $currency, false, false).' '; } // Filling-in vars for mail $template = 'new_order'; $subject = $this->l('New order'); $templateVars = array( '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, Can you please tell me what to do? Link to comment Share on other sites More sharing options...
rocky Posted October 1, 2010 Share Posted October 1, 2010 It's the first one you should change. The second one is for the vouchers section. Link to comment Share on other sites More sharing options...
dramony Posted October 2, 2010 Share Posted October 2, 2010 No, it's not that easy. You will need to get the category to get its name. Change line 108 of modules/mailalerts/mailalerts.php (in PrestaShop v1.3.1) from: $itemsTable .= to: $category = new Category($product['id_category_default'], $id_lang); $itemsTable .= Then you can use $category->name where you want the product category displayed. how to use this:Then you can use $category->name where you want the product category displayed. i want it to be like this: Product Category''.$product['name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').''.Tools::displayPrice($price * ($tax + 100) / 100, $currency, false, false).''.intval($product['quantity']).''.Tools::displayPrice(intval($product['quantity']) * ($price * ($tax + 100) / 100), $currency, false, false).''; Link to comment Share on other sites More sharing options...
dramony Posted October 2, 2010 Share Posted October 2, 2010 this should be the output (please see attachment) Link to comment Share on other sites More sharing options...
rocky Posted October 2, 2010 Share Posted October 2, 2010 Try changing: $itemsTable .= ' '.$product['reference'].' to: $category = new Category($product['id_category_default'], $id_lang); $itemsTable .= ' '.$category->name.' then change "Reference" to "Category" in order_conf.html. Link to comment Share on other sites More sharing options...
dramony Posted October 2, 2010 Share Posted October 2, 2010 okay, thank you so much Rocky! You rock! Link to comment Share on other sites More sharing options...
mytheory. Posted October 28, 2010 Share Posted October 28, 2010 Is there a way to add the product's manufacturer name right before the product name without creating a new column.Sounds like it would be easier to do, but can you just use $product['manufacturer'] to pull the manufacturer name?Preferably, under the "Product" column of emails it would say "Manufacturer - Product Name - Attributes (if any)"Thanks! Link to comment Share on other sites More sharing options...
rocky Posted October 28, 2010 Share Posted October 28, 2010 The order details doesn't include the manufacturer name, so you will have to get it using the following code: $manufacturer = new Manufacturer($product['id_manufacturer'], $id_lang); Then you can use $manufacturer->name to write the manufacturer name in front of the product name. Link to comment Share on other sites More sharing options...
mytheory. Posted October 28, 2010 Share Posted October 28, 2010 Thanks rocky!Just to make sure, since I have limited methods of testing it. $manufacturer = new Manufacturer($product['id_manufacturer'], $id_lang); $itemsTable = ''; foreach ($params['cart']->getProducts() AS $key => $product) { $unit_price = Product::getPriceStatic($product['id_product'], true, $product['id_product_attribute']); $price = Product::getPriceStatic($product['id_product'], true, $product['id_product_attribute'], 6, NULL, false, true, $product['quantity']); $itemsTable .= ' '.$product['reference'].' '.$manufacturer->name.' - '.$product['name'].(isset($product['attributes_small']) ? ' - '.$product['attributes_small'] : '').(isset($product['instructions']) ? ' '.$product['instructions'] : '').' '.Tools::displayPrice($unit_price, $currency, false, false).' '.intval($product['quantity']).' '.Tools::displayPrice(($price * $product['quantity']), $currency, false, false).' '; } Is this how it should look?Thanks! Link to comment Share on other sites More sharing options...
rocky Posted October 28, 2010 Share Posted October 28, 2010 You must move the first line inside the foreach loop, but otherwise, it looks right. Link to comment Share on other sites More sharing options...
dramony Posted November 3, 2010 Share Posted November 3, 2010 hi Rocky,got an error, instead of the Category name, "Home" is appearing. Link to comment Share on other sites More sharing options...
rocky Posted November 3, 2010 Share Posted November 3, 2010 The product must have the default category set to the "Home" category. Change the default category of the product to the category you want to appear. Link to comment Share on other sites More sharing options...
dramony Posted November 3, 2010 Share Posted November 3, 2010 Thanks man! Awesome! Link to comment Share on other sites More sharing options...
willdebeest Posted November 10, 2010 Share Posted November 10, 2010 On a similar theme. I have a client who wishes the mailalert new_order to show the order list in a particular way. Rather than simply show the list in the order the customer placed the items in the cart, he wants them in order of categories; so, fo example,all items from category 5, then all items from category 1, then all items from category 6 etc:would this be possible? Link to comment Share on other sites More sharing options...
DylzEn Posted October 14, 2012 Share Posted October 14, 2012 Hello guys. Any ideas on how to show the short description and the long description next to the product name or in separate columns? Thank you very much for your time. Dylan Link to comment Share on other sites More sharing options...
musicmaster Posted October 14, 2012 Share Posted October 14, 2012 In this context it may be nice to mention my modification. I made the products in the mailalert clickable so that you can easily check which products were ordered if the name is ambiguous. The advantage of links is that they don't take space. /* start with two lines to retrieve relevant variables */ $mycategory = Db::getInstance()->getValue("SELECT link_rewrite FROM "._DB_PREFIX_."product p, "._DB_PREFIX_."category_lang l WHERE l.id_category=p.id_category_default AND id_lang='".(int)($id_lang)."' AND p.id_product='".$product['product_id']."'"); define('_PS_BASE_URL_', Tools::getShopDomain(true)); $itemsTable .= '<tr style="background-color:'.($key % 2 ? '#DDE2E6' : '#EBECEE').';"> <td style="padding:0.6em 0.4em;">'.$product['product_id'].'</td> <td style="padding:0.6em 0.4em;"><a href="'._PS_BASE_URL_.__PS_BASE_URI__.$mycategory.'/'.$product['product_id'].'-snoep.html"><strong>'.$product['product_name'].(isset($product['attributes_small']) ? ' '.$product['attributes_small'] : '').(!empty($customizationText) ? '<br />'.$customizationText : '').'</strong></a></td> <td style="padding:0.6em 0.4em; text-align:right;">'.Tools::displayPrice($unit_price, $currency, false).'</td> <td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['product_quantity']).'</td> <td style="padding:0.6em 0.4em; text-align:right;">'.Tools::displayPrice(($unit_price * $product['product_quantity']), $currency, false).'</td> </tr>'; Link to comment Share on other sites More sharing options...
DylzEn Posted October 15, 2012 Share Posted October 15, 2012 In this context it may be nice to mention my modification. I made the products in the mailalert clickable so that you can easily check which products were ordered if the name is ambiguous. The advantage of links is that they don't take space. Well, thank you very much for sharing this, musicmaster. That works really well, and I'll surely use it if I don't come up with a solution to my problem. Because the thing is that I have orders with more than 10 products most of the time, so it would take a lot of time to click on the link, get 1 product from the stock and repeat that 10+ times. What I'd like to do is just print the new order mail with the products descriptions so I can grab all the products from the stock with a glance. But your solution is better than the default behaviour anyway, so thanks again. Dylan Link to comment Share on other sites More sharing options...
musicmaster Posted October 17, 2012 Share Posted October 17, 2012 (edited) You will have to insert two extra lines in the itemsTable. It will look something like: <td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['description']).'</td> <td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['description_short']).'</td> But this is from the top of my head. You would need to test it and I don't have time for that. I have to make up for all the time I lost with a failed upgrade. An alternative is to add the following at the end of the itemsTable: <tr><td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['description']).'</td></tr> <tr><td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['description_short']).'</td></tr> Edited October 18, 2012 by musicmaster (see edit history) Link to comment Share on other sites More sharing options...
musicmaster Posted October 18, 2012 Share Posted October 18, 2012 Wangwu, why don't you try for yourself. It takes one minute to do the experiment! Link to comment Share on other sites More sharing options...
DylzEn Posted October 18, 2012 Share Posted October 18, 2012 (edited) You will have to insert two extra lines in the itemsTable. It will look something like: <td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['description']).'</td> <td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['description_short']).'</td> But this is from the top of my head. You would need to test it and I don't have time for that. I have to make up for all the time I lost with a failed upgrade. An alternative is to add the following at the end of the itemsTable: <tr><td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['description']).'</td></tr> <tr><td style="padding:0.6em 0.4em; text-align:center;">'.(int)($product['description_short']).'</td></tr> That doesn't seem to work as descriptions are still not showed in the email table. Thank you for your time anyway, I really appreciate it. EDIT: Solved by another user here on the forums, here's his solution: Hi there, you'd have to add code to the mailalerts module php file. modules > mailalerts > mailalerts.php In the function hookNewOrder, the product details are read in from ps_order_detail in the database, which doesn't store the descriptions. An easier way would be to add product references e.g supplier codes or just tags as those do get stored in the order_details table but if you want the descriptions, you can make an instance of the product class and read the data. Just before $itemsTable .= insert the following: $prod_tmp = new Product((int)$product['product_id']); $pdescription = $prod_tmp->description[$id_lang]; $pdescription_short = $prod_tmp->description_short[$id_lang]; You'd then put $pdescription or $pdescription_short somewhere in the table. You can put it in a new column by say duplicating the product_reference line: <td style="padding:0.6em 0.4em;">'.$product['product_reference'].'</td> <td style="padding:0.6em 0.4em;">'.$pdescription.'</td> Edited October 19, 2012 by DylzEn (see edit history) Link to comment Share on other sites More sharing options...
josal Posted November 15, 2012 Share Posted November 15, 2012 Following this discussion, I would like to add the descriptions of all the combinations in the new order confirmation email (and later in some places more). So, I'm trying to modify the /modules/mailalerts/mailalerts.php file, where the $itemsTable is assigned. Concretely I want to change the value of $product['attributes_small'], because it has only the first combination for the product, and the second combination is very important also for our business. The first question is regarding this value, because maybe there is a $product['attributes'] variable or similar with all the combinations, not only the first one. Second question, it's strange because if I modify the /modules/mailalerts/mailalerts.php file, for example, changing the color of a row inside the $itemsTable, if I make a new order, the table has the same format, not including the modification. It seems like it's not taking this file to build the email... :s If this can work, I would write a simple var_dump($product) there to see the fields of the variable, but it doesn't change anything... I don't know what I'm doing wrong. Thanks for your help in advance! I'm using Prestashop 1.4.6.2. Link to comment Share on other sites More sharing options...
Recommended Posts