Jump to content

MovedBiscuit73

New Members
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

1 Neutral

About MovedBiscuit73

  • Rank
    Newbie
  1. MovedBiscuit73

    Send customer order email

    Hey thanks heaps!! I will give this a try and see how we go. :-)
  2. MovedBiscuit73

    Send customer order email

    Hello - thanks for your answer. Can you give me some example code with regard to the last sentence? So there is one email and each product ordered. Many thanks.
  3. MovedBiscuit73

    Send customer order email

    I need a fresh set of eyes. This is the link to the website: http://hermanshivehire.biz/index.php Basically its purpose is to send an email to a customer summarizing their order. The issue I'm having is with the foreach statement . When the email is sent to admin - an email is sent for each product item. The figures and totals are all correct. I have tried closing the foreach in different places and this results is one email but there is no loop for the product items. Here is my code (you can copy it into notepad++): <?php $member_id = $_SESSION['memberID']; $query = "INSERT INTO tbl_order (orderDate, order_memberID_F) VALUES (NOW(), '$member_id')"; // $orderDate = datetime(now); mysqli_query($link, $query); // retrieve the order id from tbl_order $orderID = mysqli_insert_id($link); // decode product id from $_SESSION['cart'] $cart = $_SESSION['cart']; $items = explode(',', $cart); // $items is an array now $content = array(); // declares $content as array foreach ($items as $productID) { if (isset($content[$productID])) $content[$productID] = $content[$productID] +1; else $content[$productID] = 1; // $content[$productID] = (isset($content[$productID]))?$content[$productID] + 1:1; SHORTENED VERSION OF ABOVE IF } // end of foreach // store $content into tbl_order_product foreach ($content as $product_id=>$qty) { // retrieve product price AND name from tbl_product $query = "SELECT * FROM tbl_product WHERE productID ='$product_id' "; $result = mysqli_query($link, $query); $row = mysqli_fetch_array($result); $price = $row['price']; //value from database $prodName = $row['name']; //value from database $total = $qty*$price; $grandTotal = $grandTotal + ($qty*$price); $query = "INSERT INTO tbl_order_product (orderID_F, productID_F, orderQuantity, orderPrice) VALUES ('$orderID', '$product_id', '$qty', '$price')"; mysqli_query($link, $query); unset($_SESSION['cart']); // destroys the cart session } // end of foreach //send email TO admin WITH ORDER DETAILS $email_to = "info@hermanshivehire.biz"; // your email address send TO $email_from = "info@hermanshivehire.biz"; // your email address send FROM $subject = "RE: New Website Order to Fulfill"; // From $header = 'From: '.$email_from."\r\n". 'Reply-To: '.$email."\r\n" ; // email message content $message="\n Hi Rebecca and Craig! \n There is a new order to fulfill.\n Please contact them to arrange payment.\n The order as follows: _______________________________________________________________________ Name: $custName Email: $email Address: $address Phone: $phone OrderID: $orderID Product name: $prodName Order quantity: $qty Order price: $$price each Total: $$total.00 Grand Total: $$grandTotal.00 _______________________________________________________________________ Warm regards,\n Hermans Hive Hire "; //send email $sentMailAdmin = mail($email_to, $subject, $message, $header); // mail() to admin email ?> Your assistance is much appreciated!
  4. MovedBiscuit73

    Sup Guys php Noob

    Hey there - I'm a coder from Christchurch NZ. I recently studied Web Dev and Software Dev. I am looking at polishing my php skills.
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.