On 9/28/2021 at 4:07 PM, Timéo007 said:@Galadrum, j’ai testé ceci mais mon problème n’est pas encore résolu, est-ce que vous avez une autre astuce?
Salut. Pour avoir un lien vers les affiches produits. Il faut faire quelques étapes :
1 - Crée un override pour les 2 fichiers "OrderHistory.php" et "Mail.php".
2 - Dans override/classes/order/OrderHistory.php :
Créer le bouton dans la fonction sendEmail() :
<?php public function sendEmail($order, $template_vars = false){ /................................................/ $products = $order->getProducts(); /************************************************/ /**Insérer ce code juste après*/ foreach($products as &$product) { array_push($product_id, $product['product_id']); array_push($product_name, $product['product_name']); array_push($product_buttom, '<button class="button-avis" style="background-color: #DCDCDC;">Donner mon avis</button>'); array_push($image_dir,_PS_IMG_DIR_.'p/'.$product['image']->getExistingImgPath().'.jpg'); array_push($product_link,Context::getContext()->link->getProductLink( (int)$product['product_id'], $product['link_rewrite'], $product['category'], $product['ean13'] )); } for ($i=0; $i < $data['{nbProducts}']; $i++) { $data['{product_id_'.$i.'}'] = $product_id[$i]; $data['{product_name_'.$i.'}'] = $product_name[$i]; $data['{product_buttom_'.$i.'}'] = $product_buttom[$i]; $data['{image_dir_'.$i.'}'] = $image_dir[$i]; $data['{product_link_'.$i.'}'] = $product_link[$i]; } /***************************************************/
3 - Dans override/classes/Mail.php :
<?php public static function Send($id_lang, $template, $subject, $template_vars, $to, $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null, $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null) { /.............................../ if (isset($reply_to) && $reply_to) $message->setReplyTo($reply_to); $template_vars = array_map(array('Tools', 'htmlentitiesDecodeUTF8'), $template_vars); $template_vars = array_map(array('Tools', 'stripslashes'), $template_vars); /*****************************************************/ /*Insérer ce portion de code juste après!*/ for ($i=0; $i < $template_vars['{nbProducts}']; $i++) { $template_vars['{product_id}'] .= $template_vars['{product_id_'.$i.'}'].'<br>'; $template_vars['{product_name}'] = '<div class="product_name col-sm-6" style="margin-left:15px;width:50%;margin-bottom:10px;"><p>'.$template_vars['{product_name_'.$i.'}'].'</p></div>'; $template_vars['{product_buttom}'] = '<div class="product_buttom col-sm-3" style="margin-top:15px;width:30%;"><a href="'.$template_vars['{product_link_'.$i.'}'].'">'.$template_vars['{product_buttom_'.$i.'}'].'</a></div>'; $template_vars['{image_dir}'] .= $template_vars['{image_dir_'.$i.'}']; $template_vars['{product_image}'] ='<div class="product_image col-sm-3" style="margin-top:14px;"><img style="display:block;margin-left:auto;margin-right:auto;" src="'.$message->attach(new Swift_Message_EmbeddedFile(new Swift_File($template_vars['{image_dir_'.$i.'}']), null, ImageManager::getMimeTypeByExtension($template_vars['{image_dir_'.$i.'}']))).'"width="55px" height="55px" /></div>'; $template_vars['{products}'] .='<div class="products">'.$template_vars['{product_image}'].''.$template_vars['{product_name}'].''.$template_vars['{product_buttom}'].'</div>'; } /*******************************************************/
4 - Créer votre Template de mail dans le dossier mails/ :
ajouter par exemple avis.html :
Insérer ce bloc de code dedans :
<div class="box-product" style="border:1px solid #D6D4D4;width:100%;"> {products} </div>
Ajuster l'affichage après par des propriétés CSS.