<?php 











class ControllerAliexpress extends Controller {











	var $error = array();















  	function index() {







//ini_set("display_errors", "On");



		



		$database  =& $this->locator->get('database');



		$language  =& $this->locator->get('language');



		$order     =& $this->locator->get('order');



		$request   =& $this->locator->get('request');	



		$response =& $this->locator->get('response');







		 if (!$request->isPost() || !isset($_REQUEST['reference'])) {



			 return;}











		 $order_info = $database->getRow("SELECT * FROM `order_data` WHERE `reference` LIKE '".$_REQUEST['reference']."'");











		  if(!$order_info)



    	 {



    	 	$this->checkoutorder($_REQUEST['reference']);



			



			$order_info = $database->getRow("SELECT * FROM `order_data` WHERE `reference` LIKE '".$_REQUEST['reference']."'");



				 



			if (!$order_info)



			{



				echo "<script language=\"JavaScript\">alert(\"Update order failure, return @ catalog/controller/aliexpress.php line 35\");</script>";



				return;



			}



    	 }







//    	$response->redirect("https://www.beststoreitems.com/index.php?controller=potential_order&reference=".$_REQUEST['reference']);



    	



		$template =& $this->locator->get('template');















		$module   =& $this->locator->get('module');















		$language->load('controller/potential_order.php');















		$template->set('title', $language->get('heading_title'));











    	$response->set($this->getForm());	







  	}











  	function getForm() {



		$request  =& $this->locator->get('request');



		$database =& $this->locator->get('database');



		$url      =& $this->locator->get('url');



		$language =& $this->locator->get('language');



		$currency =& $this->locator->get('currency');



		$address  =& $this->locator->get('address');



		$order     =& $this->locator->get('order');



		$coupon    =& $this->locator->get('coupon');



		$payment   =& $this->locator->get('payment');	



        $image    =& $this->locator->get('image');



        $config   =& $this->locator->get('config');



    	$view = $this->locator->create('template');



        $response =& $this->locator->get('response');		



		$tax       =& $this->locator->get('tax');



		



    	$view->set('heading_title', $language->get('heading_title') . ' #' . $request->get('order'));















    	$view->set('heading_description', $language->get('heading_description'));















    	$view->set('text_order', $language->get('text_order'));















		$view->set('text_email', $language->get('text_email'));















		$view->set('text_telephone', $language->get('text_telephone'));















		$view->set('text_fax', $language->get('text_fax'));















		$view->set('text_shipping_address', $language->get('text_shipping_address'));















    	$view->set('text_shipping_method', $language->get('text_shipping_method'));















    	$view->set('text_payment_address', $language->get('text_payment_address'));















    	$view->set('text_payment_method', $language->get('text_payment_method'));















    	$view->set('text_order_history', $language->get('text_order_history'));















    	$view->set('text_order_download', $language->get('text_order_download'));















    	$view->set('text_order_update', $language->get('text_order_update'));















    	$view->set('text_product', $language->get('text_product'));















    	$view->set('text_model', $language->get('text_model'));















    	$view->set('text_quantity', $language->get('text_quantity'));















    	$view->set('text_price', $language->get('text_price'));















    	$view->set('text_total', $language->get('text_total'));















    	$view->set('column_date_added', $language->get('column_date_added'));















    	$view->set('column_status', $language->get('column_status'));















    	$view->set('column_download', $language->get('column_download'));















    	$view->set('column_filename', $language->get('column_filename'));















    	$view->set('column_remaining', $language->get('column_remaining'));















    	$view->set('column_notify', $language->get('column_notify'));















    	$view->set('column_comment', $language->get('column_comment'));















    	$view->set('entry_status', $language->get('entry_status'));















    	$view->set('entry_comment', $language->get('entry_comment'));















    	$view->set('entry_notify', $language->get('entry_notify'));















    	$view->set('button_list', $language->get('button_list'));















    	$view->set('button_insert', $language->get('button_insert'));















    	$view->set('button_update', $language->get('button_update'));















    	$view->set('button_delete', $language->get('button_delete'));















    	$view->set('button_save', $language->get('button_save'));















    	$view->set('button_cancel', $language->get('button_cancel'));















    	$view->set('tab_general', $language->get('tab_general'));















		$view->set('error', @$this->error['message']);



    	$order_info = $database->getRow("select * from `order_data` where reference like '" . $request->get('reference') . "'");    	



		$order_data  = unserialize($order_info['data']);			







		$view->set('reference', $order_info['reference']);



         



		$view->set('order_id', $order_info['order_id']);



		$view->set('email', $order_data['email']);



		$view->set('telephone', $order_data['telephone']);	







    	$shipping_address = array(







      		'firstname' => $order_data['shipping_firstname'],







      		'lastname'  => $order_data['shipping_lastname'],







      		'company'   => $order_data['shipping_company'],







      		'address_1' => $order_data['shipping_address_1'],







      		'city'      => $order_data['shipping_city'],







      		'postcode'  => $order_data['shipping_postcode'],







      		'zone'      => $order_data['shipping_zone'],







      		'country'   => $order_data['shipping_country']



    	);







   	$view->set('shipping_address', $address->format($shipping_address, $order_data['shipping_address_format'], '<br />'));



    	$view->set('shipping_method', $order_data['shipping_method']);



    	$payment_address = array(



      		'firstname' => $order_data['payment_firstname'],







      		'lastname'  => $order_data['payment_lastname'],







      		'company'   => $order_data['payment_company'],







      		'address_1' => $order_data['payment_address_1'],







      		'city'      => $order_data['payment_city'],







      		'postcode'  => $order_data['payment_postcode'],







      		'zone'      => $order_data['payment_zone'],







      		'country'   => $order_data['payment_country']



    	);



    	$view->set('payment_address', nl2br($address->format($payment_address, $order_data['payment_address_format'])));







    	$view->set('payment_method', $order_data['payment_method']);







		$product_data  = array();       







    	foreach ($order_data['products'] as $product) {







            $product_data_info=$database->getRow("select product_id,image_id from product where product_id='".$product['product_id']."'");







            $image_data_info=$database->getRow("select filename from image where image_id='".$product_data_info['image_id']."'");







            $thumb_url=$image->resize($image_data_info['filename'], 100, 100);







        	$product_data[] = array(







                 'product_id' =>  $product['product_id'],







          		'name'     => $product['name'],







          		'thumb'   =>$thumb_url,



				



          		'model'    => $product['model'],







          		'option'   => $product['option'],







          		'quantity' => $product['quantity'],







          		'price'    =>  $product['price'], 



				



          		'discount' => $product['discount'],







				'total'    => $product['total'] 



        	);



    	}







    	$view->set('products', $product_data);



		// payment entry



        if ( $order->load($order_info['reference']) )



		{



			$methods = $payment->getMethods();



			foreach( $methods as $method )



			{







			if ( $method['title']==$order_data['payment_method'] )



				{



					$view->set('payment_url', $payment->getActionUrl($method['id']));



					$view->set('fields', $payment->getFields($method['id']));



				}			



			}		



		}











    	$view->set('totals', $order_data['totals']);	







		$view->set('callback',$url->ssl('account'));







		return $view->fetch('content/aliexpress.tpl');



    }















  	function sendemail()



  	{  







 		$request  =& $this->locator->get('request');















		$response =& $this->locator->get('response');















		$database =& $this->locator->get('database');















		$url      =& $this->locator->get('url');















		$customer =& $this->locator->get('customer');















        $mail     =& $this->locator->get('mail');















        $config   =& $this->locator->get('config');







        $image    =& $this->locator->get('image');







  		if ($request->isPost()) {















  			 $order= $database->getRow("select * from `order_data` where reference = '" . $request->get('reference','post') . "'");















		     $order_info  = unserialize($order['data']);







		     $payment_customer_info=$database->getRow("select country_id from customer where customer_id='".$customer->getId()."'");	







	







             $aliexpress_url='https://www.moneygram.com/wps/portal/moneygramonline/home/sendmoney/!ut/p/c5/04_SB8K8xLLM9MSSzPy8xBz9CP0os3gPSxcDDxN_A0t_Q18DA08LUy8_M3NDQ4NQQ6B8JG55MxOSdLuHubsA5S2MjZ28XY0NLAwI6PbSj0rPyU8CujIc5G787kCRx2ITSN4AB3A00PfzyM9N1S_IDY2oDPbUBQAkSOJI/dl3/d3/L2dJQSEvUUt3QS9ZQnZ3LzZfSDlEMEg0TzA5TzFNMDBJODVKTjY3MTEwRzI!/#';







         







		     $currency_info=$database->getRow("select * from currency where code='".$order_info['currency']."'");	







			 $user_id=$customer->getId();















             $results_email = $database->getRow("select email from customer where customer_id = $user_id");            















             $email_user=$results_email['email'];                    















             $mail->setTo($email_user);            















			 $mail->setFrom($config->get('config_email'));           















	    	 $mail->setSender($config->get('config_store'));           















	         $mail->setSubject('Order ID #'.$request->get('reference','post').' (Waiting for MoneyGram Information)');  











			$html = '<table style="margin:0 auto;" cellspacing="0" cellpadding="0" border="0" width="650" align="center">







			 		  <tbody>











					  <tr>











					  <td>















					<html dir="ltr" lang="en">











					<head>















					<title>We have received your payment for order PO#'.$request->get('reference','post').'</title>















					<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">						















					</head>















					<body>















						<div style="background:#b90601;font:11px/30px Arial;  color:#fff; height:30px;width:650px;">















							<div align="center">















								<a href="https://www.beststoreitems.com/index.php?controller=more&path=3" target="_blank" style="color:#fff; text-decoration:none;">New Arrivals</a>















								<span style="padding:0 2px;">&middot;</span>















								<a href="https://www.beststoreitems.com/index.php?controller=more&path=1" target="_blank" style="color:#fff; text-decoration:none;">Top Sellers</a>















								<span style="padding:0 2px;">&middot;</span>















								<a href="https://www.beststoreitems.com/index.php?controller=category&path=100" target="_blank" style="color:#fff; text-decoration:none;">Promotion Zone</a>















								<span style="padding:0 2px;">&middot;</span>















								<a href="https://www.beststoreitems.com/index.php?controller=sold_today" target="_blank" style="color:#fff; text-decoration:none;">What Sold Today?</a>















								<span style="padding:0 2px;">&middot;</span>















								<a href="https://www.beststoreitems.com/index.php?controller=affiliate" target="_blank" style="color:#fff; text-decoration:none;s">Affiliate ($10 USD)</a>















								<span style="padding:0 2px;">&middot;</span>















								<a target="_blank" style="color:#fff; text-decoration:none;" href="https://www.beststoreitems.com/index.php?controller=account_login">My Account</a>















								<span style="padding:0 2px;">&middot;</span>















							    <a target="_blank" style="color:#fff; text-decoration:none;" href="https://www.beststoreitems.com/index.php?controller=knowledge_base&knowledge_id=12">Contact Us</a>     















							</div>















						</div>















						<table width="100%" cellpadding="0" cellspacing="0" border="0">















							<tbody>















								<tr>















									<td colspan="3"><img src="https://www.beststoreitems.com/media/letter3_01.jpg" /></td>                    















						  </tr>















								<tr>















									<td valign="top" style="background:#cdced2;"><img src="https://www.beststoreitems.com/media/letter3_02.jpg" /></td>















									<td width="622" valign="top">















										<table width="100%" cellpadding="0" cellspacing="0" border="0">















											<tbody>















												<tr>















													<td  width="20"></td>















													<td valign="top" style="font:11px/150% Verdana, Arial;">















														<div style="margin:8px 0;">















																<h4 style="margin:10px 0px 6px;color: #000; font:13px/150% Verdana, Arial; font-weight:bold;">Dear Customer:</h4>















																<div style="font:11px/150% Verdana, Arial; padding:0 0 5px;">Thanks for your order at beststoreitems.com. You have chose moneygram payment method, Please click "Pay Now" button or "Click Here to Pay" link below to pay your order. When you send us money online, Please prepay money transfer fee, we will send you a equivalent coupon once get your payment.You may use this coupon in your next order.</div>







														 </div>       















													</td>















													<td width="72" valign="top"><img src="https://www.beststoreitems.com/media/letter3_04.jpg" /></td>















												</tr>















											</tbody>















										</table>















										<table cellpadding="0" cellspacing="0" border="0">















											<tbody>















												<tr>















													<td width="20"></td>















													<td width="582">







														<div style="font:11px/150% Verdana, Arial; padding:0 0 10px;">When you send us money online via moneygram site or agent.&nbsp;Please refer to the following payment information:







														</div>







														<table width="100%" height="83" cellspacing="0" cellpadding="0" border="0" style="border-top:1px solid #ddd;border-left:1px solid #ddd;margin-bottom:10px;">







															<tbody>







																<tr>







																	<td width="137" style="font:bold 11px/150% Verdana, Arial; padding:6px 0;text-indent:15px;border-bottom:1px solid #ddd;border-right:1px solid #ddd;"><strong>First Name</strong></td>







																	<td width="352" style="font:11px/150% Verdana, Arial; padding:6px 0;text-indent:15px;border-bottom:1px solid #ddd;border-right:1px solid #ddd;">GANG</td>







																</tr>







																<tr>







																	<td width="137" style="font:bold 11px/150% Verdana, Arial; padding:6px 0;text-indent:15px;border-bottom:1px solid #ddd;border-right:1px solid #ddd;"><strong>Last Name</strong></td>







																	<td width="352" style="font:11px/150% Verdana, Arial; padding:6px 0;text-indent:15px;border-bottom:1px solid #ddd;border-right:1px solid #ddd;">CHEN</td>







																</tr>







																<tr>







																	<td style="font:bold 11px/150% Verdana, Arial; padding:6px 0;text-indent:15px;border-bottom:1px solid #ddd;border-right:1px solid #ddd;"><b>Country</b></td>







																	<td style="font:11px/150% Verdana, Arial; padding:6px 0;text-indent:15px;border-bottom:1px solid #ddd;border-right:1px solid #ddd;">China</td>







																</tr>







															</tbody>







														</table>







														<div style="font:11px/150% Verdana, Arial; padding:0 0 5px;">If you have paid sucessfuly, Please email the following info to <a href="mailto:sales@beststoreitems.com" style="color:blue;">sales@beststoreitems.com</a>, We will process your order at the first time.</div>















																<div style="font:11px/180% Verdana, Arial;">																	







																	1. Reference number:<br />







																	2. Sender First Name:<br />







																	3. Sender Last Name:<br />







																	4. Send Amount:<br />







																	5. Money Transfer Fee:<br />







																</div>







																<div style="font:11px/150% Verdana, Arial; padding:0 0 5px; margin:5px 0;">Learn more about Money Gram, Please visit <a href="http://www.moneygram.com" target="_blank">www.moneygram.com</a>







																







																	</div>















														<div style="border:1px solid #ddd; padding:5px; background:#fbfbfb;">















															<table width="550"  cellpadding="0" cellspacing="0" border="0">















																	<tbody>















																		<tr>















																			<td style="font:11px/150% Verdana, Arial, Helvetica, sans-serif; color:#000; width:33.3%; vertical-align:top; "><b>Order Referency</b><br />















																			'.$request->get('reference','post').'<br />















																			<br />















																			<b>E-Mail</b><br />















																			'.$order_info['email'].'<br />















																			<br />















																			<b>Telephone</b><br />















																			'.$order_info['telephone'].'<br />















																			<br />















																			<b>Payment Method</b><br />















																			'.$order_info['payment_method'].'</td>















																			<td style="font:11px/150% Verdana, Arial, Helvetica, sans-serif; color:#000; width:33.3%;vertical-align:top; ">          <b>Shipping Address</b><br />















																			'.$order_info['shipping_lastname'].' '.$order_info['shipping_firstname'].'<br />'.$order_info['telephone'].'<br />'.$order_info['shipping_address_1'].'<br />'.$order_info['shipping_postcode'].' '.$order_info['shipping_city'].'<br />'.$order_info['shipping_zone'].'<br />'.$order_info['shipping_country'].'</td>















																			<td style="font:11px/150% Verdana, Arial, Helvetica, sans-serif; color:#000; width:33.3%; vertical-align:top; "><b>Payment Address</b><br />















																			'.$order_info['payment_lastname'].' '.$order_info['payment_firstname'].'<br />'.$order_info['telephone'].'<br />'.$order_info['payment_address_1'].'<br />'.$order_info['payment_postcode'].' '.$order_info['payment_city'].'<br />'.$order_info['payment_zone'].'<br />'.$order_info['payment_country'].'</td>















																		</tr>















																	</tbody>















																</table>







														</div> 















														<div style="height:10px"></div>











														<div style="border:1px solid #ddd; padding:5px; background:#fbfbfb;">











														<table width="550" class="c">















																	<tr style="font:11px/150% Verdana, Arial, Helvetica, sans-serif; color:#000; font-weight:bold;">















																		<th align="left" width="280">Product</th>















																		<th align="center">Item No.</th>















																		<th align="center">Quantity</th>















																		<th align="center">Unit Price</th>















																		<th align="right">Total</th>















																	  </tr>











																	  ';















														if($order_info['products']){















															foreach ($order_info['products'] as $pro_info){







    		$currency_info=$database->getRow("select * from currency where code='".$order_info['currency']."'");			



			$price=(strlen($pro_info['price'])>6)?$pro_info['price']:$currency_info['symbol_left'].' '.round($pro_info['price']*$order_info['value'],2);



			$total=(strlen($pro_info['total'])>6)?$pro_info['total']:$currency_info['symbol_left'].' '.round($pro_info['total']*$order_info['value'],2);







																 $product_data_info=$database->getRow("select product_id,image_id from product where product_id='".$pro_info['product_id']."'");







		                                                         $image_data_info=$database->getRow("select filename from image where image_id='".$product_data_info['image_id']."'");







		                                                         $thumb_url=$image->resize($image_data_info['filename'], 100, 100);







																 $html.='<tr>







		







																		<td align="left" width="280" style="font:11px/150% Verdana, Arial; padding:6px 0;">







																			<div style="float:left;"><a href="https://www.beststoreitems.com/index.php?controller=product&product_id='.$pro_info['product_id'].'"><img width="65" height="65" border="0" src="'.$thumb_url.'" ></a></div>







																			<div style="loat:left; width:205px; padding-left:5px; overflow:hidden;"><a style="font-size:10px; color:blue;" target="_blank" href="https://www.beststoreitems.com/index.php?controller=product&product_id='.$pro_info['product_id'].'">'.$pro_info['name'].'</a></div>







																		</td>















																		<td align="center" style="font:11px/150% Verdana, Arial; padding:4px 0;">'.$pro_info['product_id'].'</td>















																		<td align="center" style="font:11px/150% Verdana, Arial; padding:4px 0;">'.$pro_info['quantity'].'</td>















																		<td align="center" style="font:11px/150% Verdana, Arial; padding:4px 0;">'.$pro_info['price'].'</td>















																		<td align="right"  style="font:11px/150% Verdana, Arial; padding:4px 0;">'.$pro_info['total'].'</td>















																	  </tr>';	















															}















														}















														$html.='















														</table>















															















															<div class="f">















																<div style="float:right;">















																			  <table>';















																	if($order_info['totals']){















																		foreach ($order_info['totals'] as $totals){















																		$html.= '<tr>















																					<td style="font:11px/150% Verdana, Arial; text-align:right; padding-right:10px;">'.$totals['title'].'</td>















																					<td style="font:11px/150% Verdana, Arial; text-align:right;">'.$totals['text'].'</td>















																				 </tr>';















																		}















																	}















																	$html.='</table></div>















																<div style="clear:both;"></div>















															</div>











															</div> 















																<div style="height:10px;"></div>







																<div align="right"><a href="'.$aliexpress_url.'" target="_blank"><img src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/btn_paynowCC_LG.gif" border="0"/></a></div>







																<div align="right" style="margin-top:5px;"><a target="_blank" href="'.$aliexpress_url.'" style="color:red;font-size:18px; font-family:arial;"><font size="5" face="Times New Roman"></font>Or Click Here to Pay</a></div>











																<div>















																	<p style="margin:0; padding:0; height:38px; background:url(https://www.beststoreitems.com/media/letter3_06.jpg) no-repeat"></p>















																	<p style=" font:11px/40px Arial, Helvetica, sans-serif;margin: 0px 0px 10px; color:#666;text-align: right; border-bottom: 3px solid #e9e9e9;">beststoreitems.com 















							</p>







																</div>















															</td>















															<td width="20"></td>















															</tr>















															<tr>















																<td colspan="3"><img src="https://www.beststoreitems.com/media/letter3_05.jpg" /></td>















															</tr>















															</tbody>















														</table>















									</td>











									<td valign="top" style="background:#cdced2;"><img src="https://www.beststoreitems.com/media/letter3_03.jpg" /></td>















								</tr>















							</tbody>















						</table>















    					</td>















						</tr>















						</tbody>















					</table>';		







		if(!empty($order_info)){



			



			 $mail->setHtml($html);	 



		}







	    	 $mail->send();







	    	 echo "<script>alert('it will take you to MoneyGram website to pay. your order has already been saved in your account. You also may pay it in the future, Please remember to email us your payment detail once you sent us money.');self.location='".$aliexpress_url."';</script>";    







  		}



  	}







	function checkoutorder($reference)



	{    



		



		$address   =& $this->locator->get('address');







		$calculate =& $this->locator->get('calculate');  	







		$cart      =& $this->locator->get('cart');







		$config    =& $this->locator->get('config');



		



	$coupon   =& $this->locator->get('coupon');







		$currency  =& $this->locator->get('currency');







		$customer  =& $this->locator->get('customer');







		$database  =& $this->locator->get('database');







		$language  =& $this->locator->get('language');







		$module    =& $this->locator->get('module');







		$order     =& $this->locator->get('order');







		$payment   =& $this->locator->get('payment');







		$request   =& $this->locator->get('request');	







		$session   =& $this->locator->get('session');







		$shipping  =& $this->locator->get('shipping');







		$tax       =& $this->locator->get('tax');







		$template  =& $this->locator->get('template');







		$url       =& $this->locator->get('url');



		



		$image    =& $this->locator->get('image');







				



		$totals = $calculate->getTotals();			



		



    	$product_data = array();







    	foreach ($cart->getProducts() as $product) {



      		$option_data = array();







      		foreach ($product['option'] as $option) {



        		$option_data[] = array(







          			'name'  => $option['name'],







          			'value' => $option['value']



        		);



      		} 



      		$product_data[] = array(







				'product_id' => $product['product_id'],







        		'href'       => $url->href('product', FALSE, array('product_id' => $product['product_id'])),







        		'name'       => $product['name'],







        		'model'      => $product['model'],







        		'thumb'    => $image->resize($product['image'], 100, 100),







        		'option'     => $option_data,







        		'quantity'   => $product['quantity'],







				'tax'        => $tax->getRate($product['tax_class_id']),







        		'price'      => $currency->format($tax->calculate($product['price'], $product['tax_class_id'], $config->get('config_tax'))),



        		



        		'amount'      => $tax->calculate($product['price'], $product['tax_class_id'], $config->get('config_tax')),







				'discount'   => ($product['discount'] ? $currency->format($tax->calculate($product['price'] - $product['discount'], $product['tax_class_id'], $config->get('config_tax'))) : NULL),







        		'total'      => $currency->format($tax->calculate($product['total'], $product['tax_class_id'], $config->get('config_tax')))



      		); 



    	} 







		$order->set('products', $product_data);







		$order->set('totals', $totals);			







		$order->set('customer_id', $customer->getId());







		$order->set('firstname', $customer->getFirstName());







		$order->set('lastname', $customer->getLastName());







		$order->set('email', $customer->getEmail());







		$order->set('telephone', $customer->getTelephone());		







		$order->set('order_status_id', $config->get('config_order_status_id'));







		$order->set('total', $cart->getTotal());







		$order->set('currency', $currency->getCode());







		$order->set('value', $currency->getValue($currency->getCode()));







		$order->set('ip', $_SERVER['REMOTE_ADDR']);







		$order->set('shipping_firstname', $address->getFirstName($session->get('shipping_address_id')));







		$order->set('shipping_lastname', $address->getLastName($session->get('shipping_address_id')));







		$order->set('shipping_company', $address->getCompany($session->get('shipping_address_id')));







		$order->set('shipping_address_1', $address->getAddress1($session->get('shipping_address_id')));







		$order->set('shipping_city', $address->getCity($session->get('shipping_address_id')));







		$order->set('shipping_postcode', $address->getPostCode($session->get('shipping_address_id')));







		$order->set('shipping_zone', $address->getZone($session->get('shipping_address_id')));







		$order->set('shipping_country', $address->getCountry($session->get('shipping_address_id')));







		$order->set('shipping_address_format', $address->getFormat($session->get('shipping_address_id')));







		$order->set('shipping_method', $shipping->getTitle($session->get('shipping_method')));







		$order->set('payment_firstname', $address->getFirstName($session->get('payment_address_id')));







		$order->set('payment_lastname', $address->getLastName($session->get('payment_address_id')));







		$order->set('payment_company', $address->getCompany($session->get('payment_address_id')));







		$order->set('payment_address_1', $address->getAddress1($session->get('payment_address_id')));







		$order->set('payment_city', $address->getCity($session->get('payment_address_id')));







		$order->set('payment_postcode', $address->getPostCode($session->get('payment_address_id')));







		$order->set('payment_zone', $address->getZone($session->get('payment_address_id')));







		$order->set('payment_country', $address->getCountry($session->get('payment_address_id')));







		$order->set('payment_address_format', $address->getFormat($session->get('payment_address_id')));







		$order->set('payment_method', $payment->getTitle($session->get('payment_method')));	



		



		$order->set('payment_method_id', $session->get('payment_method'));		







		$order->set('email_subject', $language->get('email_subject', $reference));		



		



		$order->set('comment', $session->get('comment'));







		//$order->set('email_html', $email->fetch('content/checkout_email.tpl'));







		$order->set('email_text', $language->get('email_message', $config->get('config_store'), $reference, $url->ssl('account_invoice', FALSE, array('reference' => $reference)), date($language->get('date_format_long')), strip_tags($session->get('comment'))));







		$order->save($reference);



     



 }











	function validate() {











		$coupon   =& $this->locator->get('coupon');















		$language =& $this->locator->get('language');















		$request  =& $this->locator->get('request');















		$cart      =& $this->locator->get('cart');















		if (!$coupon->set($request->get('coupon', 'post'))) {















			$this->error['message'] = $language->get('error_coupon');		











		}







		if (!$this->error) {







			return TRUE;







		} else {







			return FALSE;



		}







	}







}































?>