Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a litlle problem for me

Status
Not open for further replies.

sophielois

Technical User
Sep 8, 2005
66
GB
Hi guys and galls,

well im stuk.

Im using a custom shopping cart me and a friend have been working on.

Im trying to send an email to the customer services giving details of what products have been ordered.

here's how the orderd products are displayed onscreen
Code:
 <div id="pi" style="width:597px;">Product Information <a href="cart.php">edit</a></div>
  <table width="98%" border="0" align="center">
    <tr> 
      <td align="left"><strong>ID</strong></td>
      <td align="center"><strong>Product</strong></td>
      <td align="center"><strong>Qty</strong></td>
      <td style="text-align:right;" align="right"><div align="right"><strong>Price</strong></div></td>
      <td style="text-align:right;" align="right"><div align="right"><strong>Total</strong></div></td>
    </tr>
    <? 
	$alternate = false;
	foreach ($invoice->cart->items as $id => $item) { 
		$alternate = !$alternate;
?>
    <tr class="<?= $alternate ? "a" : "b" ?>"> 
      <td> 
        <?=$id?>
      </td>
      <td align="center"> 
        <?=$item->name?>
      </td>
      <td align="center"> 
        <?=$item->qty?>
      </td>
      <td class="currency" align="right"> &pound; 
        <?=number_format($item->price, 2)?>
      </td>
      <td class="currency" align="right"> &pound; 
        <?=number_format($item->extendedPrice(), 2)?>
      </td>
    </tr>
    <? 	} ?>
    <tr class="b"> 
      <td colspan="4" align="right">FREE DELIVERY</td>
      <td class="currency" align="right">£0</td>
    </tr>
    <tr class="b"> 
      <td colspan="4" align="right"><strong>TOTAL</strong></td>
      <td class="currency" align="right"> &pound; 
        <?=number_format($invoice->getTotal(), 2)?>
      </td>
    </tr>
  </table>

and here's my current code to send the email to the customer service rep
Code:
$mailContent="$name has orderd the following products\n\n
Name: $name
Products:";
			

$toAddress="mee@mydomain.com"; 
$subject="Product Order"; 
$recipientSubject="Order from Website";  
$receiptMessage = "Thank you $name for your online order we will contact you shortly\n\nThis is an automated email please do not respond"; 
 
mail($invoice->customer->email, $subject, $receiptMessage,"From:$toAddress"); 

mail($toAddress,$recipientSubject,$mailContent,"From:$email");

The email works fine, but i cant work out what i need to put next to products: so that it displays all the ordered products?

Thanks if you can help me,

Sophster
 
loop through you're database through all the products ordered and append them to you mailtext perhaps an idea
 
what hos2 said - you'll have to get a recordset from your database, loop through it and build the text

-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
i like your sleeves...they're real big
 
Ok thanks for the info guys.

Just to let you know, as its only a small shoppiong basket we havn't used database's, our products are store in a file called products.php

and you might have to bear with us as we are in no way PHP guries, infact i would say we are PHP beginners.

If you could offer us any further advice / examples that would be really kind.


Thanks again

Soph
 
if you are going to work with shopping carts you can better learn some mysql first. there are some nice faqs on how to begin and will make you're live so much easier than working with files. ps what if 2 people order at the same time for instance ?? is everything stored in the same file ??

and with a shopping cart you have a 1:n relationship between the customer and the products ordered ?? how do you store that in a file ??
 
hos, the shopping cart actually works fine for what it is needed for. Even when 2 people order at exactly the same time.

I take your view on board and i know mysql would be useful, but is not an option for the solution to my wuestion.

So back to my origanl qustion.. Is it possible for me to email the suctomer services the list of products that have been orderd?

Thanks again

Soph
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top