[eluser]YellowShadow[/eluser]
Hey all,
I'm trying to email the cart contents to the user after the PayPal IPN result but it just sends a blank email. I don't think it actually gets the session data for the cart if the user is not on my website. Is there a workaround for this?
Here is the current code I'm using...
Code:
public function ProcessOrder()
{
if ($this->paypal_ipn->validateIPN())
{
$this->paypal_ipn->extractOrder();
$this->paypal_ipn->saveOrder();
if ($this->paypal_ipn->orderStatus == PayPal_IPN::PAID)
{
$this->load->library('email');
$this->load->model('OrdersModel');
//Inser the order into the database
$this->OrdersModel->InsertOrder();
//Send an email as a recipt
$this->email->from('[email protected]', 'Modern Engine');
$this->email->subject('Your recent order from Modern Engine');
$this->email->to($this->MembershipModel->GetEmail());
$message = 'Dear '.$this->MembershipModel->GetFullName($this->session->userdata('username')).',<br /><br />Below is the recipt for your recent purchase from Modern Engine. Please keep it for your records.<br /><br />';
$message .= '
<table border="0" cellpadding="5" cellspacing="0">
<thead>
<th>Qty</th>
<th>Item Description</th>
<th>Item Price</th>
<th>Sub-Total</th>
</thead>
<tbody>';
foreach($this->cart->contents() as $items)
{
$message .= ' <tr>
<td>'.
$items['qty'].'</td>
<td>'.$items['name'].'</td>
<td>$'.$this->cart->format_number($items['price']).'</td>
<td>$'.$this->cart->format_number($items['subtotal']).'</td>
</tr>';
}
$message .= '<tr>
<td</td>
<td></td>
<td><strong>Total</strong></td>
<td>$'.$this->cart->format_number($this->cart->total()).'</td>
</tr>
</tbody>
</table>';
$message .= 'Thanks,<br />Modern Engine<br /><br />If you have any questions please contact us at <a href="mailto:[email protected]">[email protected]</a>';
$this->email->message($message);
$this->email->send();
$this->cart->destroy();
}
}
}
Any help would be greatly appreciated!
Thanks!