mailer for product review in prestashhop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sanjay25
Forum Newbie
Posts: 1
Joined: Thu Jan 07, 2016 5:15 am

mailer for product review in prestashhop

Post by Sanjay25 »

Hi

I want to make a mailer for product review .there is some issues in their please resolve it .


Code: Select all


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
</head>


<body onload="MM_preloadImages('Hover/Facebook.png','Hover/Twitter.png','Hover/Pinterest.png','Hover/Google-Plus.png','Hover/Blogger.png')"><?php
	 error_reporting(0);


	
	global $smarty;
	global $cookie;
	include(dirname(__FILE__).'/../config/config.inc.php') ;
	$db = Db::getInstance(); // create and object to represent the database
	$dbhost = 'localhost';
	$dbuser = 'root';
	$dbpass = '';
	$conn = mysql_connect($dbhost, $dbuser, $dbpass);
	if(! $conn )
	{
	die('Could not connect: ' . mysql_error());
	}
	$selected = mysql_select_db("sanjay_homedrapedb",$conn) 
	or die("Could not select examples");
	$today = date('Y-m-d');
	$message ='';
	$date = strtotime(date('Y-m-d'));
	$date= date('Y-m-d', $date);	
	 
				
		   $result1 = mysql_query("select * from `ps_orders` where `valid` = '1'AND `review_rate`='1' AND `date_add` LIKE '$date%'")
		   or die(mysql_error("Error"));
		  
	       
		   while ($rows = mysql_fetch_array($result1))
		      {
			  
			  $cust_id[] = $rows['id_customer'];   // Fetching Customer id from database and creating an array
			  $dbdate[] = $rows['date_add'];			
			  $orderId[] = $rows['id_order'];
			  $cartid[] = $rows['id_cart'];
			   	  
		   
		      }			
			   
				foreach($dbdate as $key_dbdate=>$dbdate)
				{  
					
					list($dbdate,$time) = explode(" ",$dbdate);
					
				  
					if($dbdate == $date)
					
					{  
					  foreach($cust_id as $key_custId=>$cust_id)
					  {  
					   	
					   foreach($orderId as $keyOrder=>$order_Id)
			 			{  
						
							
						
    						// print_r($orderId);die;
							
							
							if($key_custId == $keyOrder)
							{
								
						                $query="select * from `ps_customer` where `id_customer`= '$cust_id' " or die(mysql_error());
										$result= mysql_query($query);
										 
										while($rows=mysql_fetch_assoc($result))
										{   
													
										$to =  $rows['email'];
										$subject = 'Product Review';										
									    $query = mysql_query("select `id_cart` from  `ps_orders` where `id_order` = '$order_Id'") or die(mysql_error());
										$row = mysql_fetch_assoc($query) or die(mysql_error());	
																											
										$cart_id = $row['id_cart'];									
										$sql = mysql_query("select * from `ps_cart_product` where `id_cart` = '$cart_id'");	
																			
										?>
                             
										<?php
                                    while($result = mysql_fetch_array($sql)) 
                                    {	
									
									$product_id[] = $result['id_product'];
									 
                         	
                                    }
								
                                    ?>
                                    <?php
                                    $i = 0;
                                $cout='-1';
					
							
							$order_Id = base64_encode($order_Id);
								
							/*$order_Id = base64_decode($order_Id);		*/ 	
							
							$message .= '<div class="main" style="height: auto; width: 700px; margin-right: auto; margin-left: auto;">
							<table border="0" cellpadding="00" cellspacing="000" style="box-shadow: 0px 0px 10px 2px rgba(0, 0, 0, 0.1);">
							<tr>
							<td width="719" align="center" valign="middle" style="background-color: rgba(173, 173, 173, 0.55); text-align: center; float: left; height: auto; width: 100%; padding: 8px 0 8px 0;" ><img src="						           http://localhost/homedrapelive/review_page/logo_mail.jpg" /></td>
							</tr>
							<td align="left" valign="top" style="font-family:Open Sans, sans-serif; float: left; height: auto; width: 680px; color: #373435; padding: 20px; font-size: 1.04em;
							letter-spacing: 0.5pt;
							line-height: 18pt;
							text-align:justify;">
							<p>Dear customer, </p>
							<p>We hope you have had a good time using your recent purchase.</p>
							<p>It will be great if you can share feedback on your satisfaction with the product. Your inputs are an unbiased source of information for other customers and helps them make an informed purchase decision. So, go ahead and tell us if you would recommend the product to others.</p>';
							foreach($product_id as $product_id1)
				          	{
							 	
							$sql = mysql_query("SELECT * FROM `ps_image`,`ps_image_lang` WHERE  ps_image.id_image= ps_image_lang.id_image AND ps_image.id_product = '$product_id1'  LIMIT 1,1") or die(mysql_error());
						    while($result = mysql_fetch_array($sql))
							{     	 
						 	$one = $result[0];								
							$id_image = $product_id1."-".$result['id_image']."-medium.jpg";																				
							$image_url = "http://localhost/homedrapelive/img/p/".$id_image;
							
							$cout++;
							$sql12 = mysql_query("SELECT * FROM `ps_image`,`ps_image_lang` WHERE  ps_image.id_image= ps_image_lang.id_image AND ps_image.id_product = '$product_id1' AND `id_lang` = '1' LIMIT 1,1")
							or die(mysql_error());
						    $result12 = mysql_fetch_array($sql12);	
							
						    $legend = $result12['legend'];		
									
														
							$message.='
							<table width="100%" border="1" cellpadding="000" cellspacing="000" style="border-color:#CCC 2px 3px 4px;">
							
							<tr>
							<td width="51%" align="center" valign="middle"><p><img src="'.$image_url.'" /></p>
							<p>							
							'.$legend.'
							
							</p></td>
							<td width="49%" align="center" style="color:#373435;"> <a href="http://localhost/homedrapelive/index.php?id_product='.$product_id1.'&controller=product">Review this Product </a> </td>
							
							
							</tr>							
							</table>';
							}
					       }       
					       
							$message.='
							<p>Thank you for shopping with us! </p>
							<p>Regards,
							</br>
							Team Home Drape</p>
							</td>
							</tr>							
							<tr>
							<td align="left" valign="top" style="background-color: rgba(173, 173, 173, 0.55); "><table width="97%" border="0" cellpadding="00" cellspacing="00">
							<tr>
							<td height="33" align="left" valign="middle"><table width="51%" border="0" align="center" cellpadding="10" cellspacing="0">
							<td width="24%">Follow us</td>
							<td width="15%" align="center" valign="middle"><a href="https://www.facebook.com/homebyfreedom" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage("f","","www.cannoneye.co.in/homebyfreedom/review_page/Hover/Facebook.png",1)"><img src="http://localhost/homedrapelive/review_page/Hover/Facebook.png" width="32" height="32" id="f" /></a></td>
							<td width="15%" align="center" valign="middle"><a href="https://twitter.com/homebyfreedom" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage("t","","www.cannoneye.co.in/homebyfreedom/review_page/Hover/Twitter.png",1)"><img src="http://localhost/homedrapelive/review_page/Hover/Twitter.png" width="32" height="32" id="t" /></a></td>
							<td width="15%" align="center" valign="middle"><a href="http://www.pinterest.com/homebyfreedom/" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage("p","","www.cannoneye.co.in/homebyfreedom/review_page/Hover/Pinterest.png",1)"><img src="http://localhost/homedrapelive/review_page/Hover/Pinterest.png" width="32" height="32" id="p" /></a></td>
							<td width="15%" align="center" valign="middle"><a href="https://plus.google.com/u/0/+Homebyfreedom/posts" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage("g+","","www.cannoneye.co.in/homebyfreedom/review_page/Hover/Google-Plus.png",1)"><img src="http://localhost/homedrapelive/review_page/Hover/Google-Plus.png" width="32" height="32" id="g+" /></a></td>
							</tr>
							</table></td>
							</tr>
							</table></td>
							</tr>							
							</table>
							</td>
							<tr>
							<td align="left" valign="top"><P style="font-family: Open Sans, sans-serif; font-size:0.75em; text-align: center;">Copyright(c) 2015 Homedrape.com All Rights Reserved.
							</tr>
							</table>
							</div>
							</body>
							</html>
							';
							print_r($message);
										$headers  = 'MIME-Version: 1.0' . "\r\n";
										$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
										$headers .= 'From: sanjaycannoneye@gmail.com' . "\r\n" .
										'Reply-To: sanjaycannoneye@gmail.com' . "\r\n" .
										'X-Mailer: PHP/' . phpversion();
								
						    
						     }
					    mail($to, $subject, $message, $headers) or die("Could not sent mail");
						$filename = $cust_id.".html";
						$file = fopen("$filename","w");
						fwrite($file,$message);
						fclose($file);
						
						
					 }
				  }
			   }
		 
		  
	
	}
	

	

	
}
	
                       /* foreach($orderId as $keyOrder=>$order_Id)
			 			{
							$updateresult = mysql_query("UPDATE `sanjay_homedrapedb`.`ps_orders` SET `review_rate` = '0' WHERE `ps_orders`.`id_order` = '".$order_Id."'");
							$uresult= mysql_query($updateresult);
							
							if($uresult){
								
								echo "done";
								
								
							}
							  
						}*/
	?>




User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: mailer for product review in prestashhop

Post by Celauran »

What issues are you encountering? What steps have you taken to try to resolve them? Where are you running into problems?
Post Reply