close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

multiple email sending with unique content

Thread began 7/29/2014 8:10 am by Christopher West | Last modified 8/12/2014 4:03 pm by Christopher West | 955 views | 10 replies |

Christopher WestCommunity Expert

multiple email sending with unique content

Hello, got a slight issue I need to tweak. My page does a multiple record update (for customer orders) and at the same time it will send out those customers an email notification to say their order has been updated. my form is using a checkbox beside each record, so admin can select which orders to be updated. this part works and here is my current code for the update to put it in context.

php:
<?php

if (isset($_POST["Save"])) {
  
mysql_select_db($database_dinkydb$dinkydb);
  
$query_rsOrders "UPDATE orders SET OrderProcess = '".$_POST["order-update"]."' WHERE OrderID IN (".implode(", ",$_POST["order-reference"]).")";
  
mysql_query($query_rsOrders$dinkydb);
}
?>



I have added a create email message server behaviour and clicking on the To... button I have selected recordset loop.
I have attached a screenshot. The issue I am having is that, it does send out multiple email, however in each email it display identical content...and its suppose to display dynamic content such as the customer order reference number. So my question how would I make this email send unique record detaills such as customer name, customer order number etc.

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

the this post for details:
http://www.webassist.com/forums/posts.php?id=17869

Sign in to reply to this post

Christopher WestCommunity Expert

I see so from that forum post link, all I need to do is add those extra code reference inside my php email code to allow me to then add in what every dynamic data I want which will then be unique to the email loop in the email message wizard :)

Sign in to reply to this post

Jason ByrnesWebAssist

Yup, that's correct.

Sign in to reply to this post

Christopher WestCommunity Expert

Hi Just to clarify, (just got round to doing this part)

I have my update code triggered by save buttom:

<?php
if (isset($_POST["Save"])) {
mysql_select_db($database_dinkydb, $dinkydb);
$query_rsOrders = "UPDATE orders SET OrderProcessDate = NOW() WHERE OrderID IN (".implode(", ",$_POST["order-reference"]).")";
mysql_query($query_rsOrders, $dinkydb);
}
?>
<?php
if (isset($_POST["Save"])) {
mysql_select_db($database_dinkydb, $dinkydb);
$query_rsOrders = "UPDATE orders SET OrderProcess = '".$_POST["order-update"]."' WHERE OrderID IN (".implode(", ",$_POST["order-reference"]).")";
mysql_query($query_rsOrders, $dinkydb);
}
?>



straight after I have my Create Email Message server behaviour:

with the following:
TO: <?php echo ((isset($_POST["OrderBuyerEmail"]))?$_POST["OrderBuyerEmail"]:""); ?>
as well as
Email Body: checkbox is ticked for Manage email bosy from file (and I have a blank php file where I add the content that sends to the customer.

So now I have my following files:

admin/order-progress.php
webassist/email/waue_order-progress_1.php
webassist/email/templates/order-progress.php

now to send the email to ALL the emails that were selected on the checkbox

All I need to do is edit the webassist/email/templates/order-progress.php file

For example this file contains the current code:

<?php
global $RecipArray;
global $RecipIndex;
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>

<body>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td><p><?php echo($RecipArray[$RecipIndex][0]["[OrderBuyerFirstName]"]); ?></p>
<p><?php echo($RecipArray[$RecipIndex][0]["[OrderProcess]"]); ?></p>
</td>
</tr>
</tbody>
</table>
</body>
</html>



And thats the ONLY file that needs tweaking to send out to all the email addresses I have checked?

Sign in to reply to this post

Jason ByrnesWebAssist

sounds correct, but this code:

<?php echo($RecipArray[$RecipIndex][0]["[OrderProcess]"]); ?></p>


should be:
<?php echo($RecipArray[$RecipIndex][0]["OrderProcess"]); ?></p>


the [] is not needed around the column name.

Sign in to reply to this post

Christopher WestCommunity Expert

ok brilliant. also on the same subject of emails.

if I am using the option to use my own email template as in when tick the checkbox for Manage email body from file

I can obviously use posts or sessions in my own email template so that's fine. however what about ecart objects

for example I have a paypal-success.php which stores an order in the database thats fine, and when it sends out an order I get an error:

Total Order Cost: £
Fatal error: Call to a member function GrandTotal() on a non-object in /homepages/36/d512037306/htdocs/createimpressions/projects/dinky/webassist/email/templates/order-invoice.php on line 9

and line 9 for this file reads:

<strong>Total Order Cost:</strong> &pound;<?php echo $DinkyCart->GrandTotal(); ?>

I assumed that ecart was all sessions

in my main paypal-success.php file I do have the include files:
<?php
//WA eCart Include
require_once("WA_eCart/DinkyCart_PHP.php");
?>
<?php require_once( "WA_eCart/PP_ECO_Scripts/PP_ECO_PHP.php"); ?>
<?php
//WA eCart Include
require_once("WA_eCart/WA_eCart_Database_PHP.php");
?>
<?php
$DinkyCart->GetContent();
?>

would I need to add these include files in my actual email template?

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

"would I need to add these include files in my actual email template?"

yes

Sign in to reply to this post

Christopher WestCommunity Expert

Hmm I did but now I get a different error:
Fatal error: Call to a member function GetContent() on a non-object in /homepages/36/d512037306/htdocs/createimpressions/projects/dinky/webassist/email/templates/order-invoice.php on line 12

here is the exact code of the email template file.

below the error occurs when it reaches: this snippet of code: <?php echo $DinkyCart->GrandTotal(); ?>

<?php require_once('../../../Connections/dinkydb.php'); ?>
<?php
//WA eCart Include
require_once("../../../WA_eCart/DinkyCart_PHP.php");
?>
<?php require_once( "../../../WA_eCart/PP_ECO_Scripts/PP_ECO_PHP.php"); ?>
<?php
//WA eCart Include
require_once("../../../WA_eCart/WA_eCart_Database_PHP.php");
?>
<?php
$DinkyCart->GetContent();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
.....html code here




<p style="font-family: Verdana, Geneva, sans-serif;font-size: 13px;line-height: 18px;font-weight: normal;color: #000000"><strong>Date of Order:</strong> <?php echo date('jS F Y - G:ia',strtotime($_SESSION['OrderDate'])); ?><br><br><strong>Order Number:</strong> <?php echo $_SESSION['OrderReference']; ?><br><strong>Name:</strong> <?php echo $_SESSION['BuyerSalutation']; ?> <?php echo $_SESSION['BuyerFirstName']; ?> <?php echo $_SESSION['BuyerLastName']; ?><br><strong>Telephone:</strong> <?php echo $_SESSION['BuyerPhone']; ?><br><strong>Email:</strong> <?php echo $_SESSION['BuyerEmail']; ?></p></td><td width="327" rowspan="3" align="right" valign="top"><p style="font-family: Verdana, Geneva, sans-serif;font-size: 13px;line-height: 18px;font-weight: normal;color: #000000"><strong>Total Order Cost:</strong> &pound;<?php echo $DinkyCart->GrandTotal(); ?><br><br><strong>Shipping:</strong> <?php echo $_SESSION['OrderShippingType']; ?><?php
if ("".$_SESSION['OrderDiscount'] ."" != "0") { // WebAssist Show If
?><br><strong>Discounts</strong> &pound;<?php echo $DinkyCart->GetDiscounts(); ?><?php
} // ("".$_SESSION['OrderDiscount'] ."" != "")
?><?php
if ("".$_SESSION['OrderVoucher'] ."" != "") { // WebAssist Show If
?><br><strong>Gift Voucher:</strong> <?php echo $_SESSION['OrderVoucherCode']; ?>
<?php
} // ("".$_SESSION['OrderVoucher'] ."" != "")
?><?php
if ("".$_SESSION['OrderCoupon'] ."" != "") { // WebAssist Show If
?><br><strong>Coupon:</strong> <?php echo $_SESSION['OrderCouponCode']; ?><?php
} // ("".$_SESSION['OrderCoupon'] ."" != "")
?> </p>




...html code here
</body>
</html>

Sign in to reply to this post

Jason ByrnesWebAssist

My apologies, instead of adding the include lines for the cart object, and the get content, you just need to set a global for the cart:

global $DinkyCart;

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...