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

Sending email based on product bought

Thread began 6/02/2014 8:34 am by The Flying Fox | Last modified 6/02/2014 3:28 pm by Jason Byrnes | 556 views | 7 replies |

The Flying Fox

Sending email based on product bought

Hi

I have modified code to send an email specific to the category of the item purchased.

at the moment is have just set up 3 categories and change the code in the UE code from

$EmailRef = "waue_checkout_success_1";

To

if ($CHG_cart->DisplayInfo("category") == 1) {
$EmailRef = "waue_checkout_success_1";
} else
if ($CHG_cart->DisplayInfo("category") == 2) {
$EmailRef = "waue_checkout_success_2";
} else
if ($CHG_cart->DisplayInfo("category") == 3) {
$EmailRef = "waue_checkout_success_3";
} ;

but this is sending 3 email instead of just one based on the category purchased.

Is this possible or am I just running round in circles?

Andy

Sign in to reply to this post

Jason ByrnesWebAssist

You would need to set up a universal email instance for each of the 3 categories.

then add the if statement around the entire instance, not just the email reference name.

Sign in to reply to this post

The Flying Fox

Hi Jason,

I take it you mean this instance?

<?php
if (("" == "")) {
//WA Universal Email object="mail"
@session_write_close();
set_time_limit(0);
$EmailRef = "waue_checkout_success_1";
$BurstSize = 200;
$BurstTime = 1;
$WaitTime = 1;
$GoToPage = "";
$RecipArray = array();
$StartBurst = time();
$LoopCount = 0;
$TotalEmails = 0;
$RecipIndex = 0;
// build up recipients array
$CurIndex = sizeof($RecipArray);
$RecipArray[$CurIndex] = array();
$RecipArray[$CurIndex ][] = "".(WA_getSavedFormValue("CheckoutWizard_NewFromBlank_Default","Email_Address")) ."";
$TotalEmails += sizeof($RecipArray[$CurIndex]);
$RealWait = ($WaitTime<0.25)?0.25:($WaitTime+0.1);
$TimeTracker = Array();
$TotalBursts = floor($TotalEmails/$BurstSize);
$AfterBursts = $TotalEmails % $BurstSize;
$TimeRemaining = ($TotalBursts * $BurstTime) + ($AfterBursts*$RealWait);
if ($TimeRemaining < ($TotalEmails*$RealWait) ) {
$TimeRemaining = $TotalEmails*$RealWait;
}
writeUEProgress($EmailRef,0,$TotalEmails,$TimeRemaining);
while ($RecipIndex < sizeof($RecipArray)) {
$EnteredValue = is_string($RecipArray[$RecipIndex][0]);
$CurIndex = 0;
while (($EnteredValue && $CurIndex < sizeof($RecipArray[$RecipIndex])) || (!$EnteredValue && $RecipArray[$RecipIndex][0])) {
$starttime = microtime_float();
if ($EnteredValue) {
$RecipientEmail = $RecipArray[$RecipIndex][$CurIndex];
} else {
$RecipientEmail = $RecipArray[$RecipIndex][0][$RecipArray[$RecipIndex][2]];
}
$EmailsRemaining = ($TotalEmails- $LoopCount);
$BurstsRemaining = ceil(($EmailsRemaining-$AfterBursts)/$BurstSize);
$IntoBurst = ($EmailsRemaining-$AfterBursts) % $BurstSize;
if ($AfterBursts<$EmailsRemaining) $IntoBurst = 0;
$TimeRemaining = ($BurstsRemaining * $BurstTime * 60) + ((($AfterBursts<$EmailsRemaining)?$AfterBursts:$EmailsRemaining)*$RealWait) - (($AfterBursts>$EmailsRemaining)?0:($IntoBurst*$RealWait));
if ($TimeRemaining < ($EmailsRemaining*$RealWait) ) {
$TimeRemaining = $EmailsRemaining*$RealWait;
}
$CurIndex ++;
$LoopCount ++;
writeUEProgress($EmailRef,$LoopCount,$TotalEmails,round($TimeRemaining));
wa_sleep($WaitTime);
include("../../webassist/email/waue_checkout_success_1.php");
$endtime = microtime_float();
$TimeTracker[] =$endtime - $starttime;
$RealWait = array_sum($TimeTracker)/sizeof($TimeTracker);
if ($LoopCount % $BurstSize == 0 && $CurIndex < sizeof($RecipArray[$RecipIndex])) {
$TimePassed = (time() - $StartBurst);
if ($TimePassed < ($BurstTime*60)) {
$WaitBurst = ($BurstTime*60) -$TimePassed;
wa_sleep($WaitBurst);
}
else {
$TimeRemaining = ($TotalEmails- $LoopCount)*$RealWait;
}
$StartBurst = time();
}
if (!$EnteredValue) {
$RecipArray[$RecipIndex][0] = mysql_fetch_assoc($RecipArray[$RecipIndex][1]);
}
}
$RecipIndex ++;
}
@session_start();
$_SESSION[$EmailRef."_Status"] = $GLOBALS[$EmailRef."_Status"];
$_SESSION[$EmailRef."_Index"] = $GLOBALS[$EmailRef."_Index"];
$_SESSION[$EmailRef."_From"] = $GLOBALS[$EmailRef."_From"];
$_SESSION[$EmailRef."_To"] = $GLOBALS[$EmailRef."_To"];
$_SESSION[$EmailRef."_Subject"] = $GLOBALS[$EmailRef."_Subject"];
$_SESSION[$EmailRef."_Body"] = $GLOBALS[$EmailRef."_Body"];
$_SESSION[$EmailRef."_Header"] = $GLOBALS[$EmailRef."_Header"];
$_SESSION[$EmailRef."_Log"] = $GLOBALS[$EmailRef."_Log"];
if (function_exists("rel2abs")) $GoToPage = $GoToPage?rel2abs($GoToPage,dirname(__FILE__)):"";
if ($GoToPage!="") {
header("Location: ".$GoToPage);
}
}
?>


would I just copy the code or create it from scratch

Andy

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, that is the code block for a UE server behavior.

dont copy it, create the other 2 instances of the server behavior.

Webassist -> Create Email Message

to create the emails for each category, then add the if statement around the UE server behaviors so the correct one triggers depending on the category.

If you need further assistance with this, I Would suggest signing up for a premiere support appointment:
http://www.webassist.com/premier_request.php

Sign in to reply to this post

The Flying Fox

Hi Jason

I think i've got this one sorted just a quick one with the category

if ($CHG_cart->DisplayInfo("category") == 1)

as my category is a numeric value for the index would I surround the 1 in quotes or leave as it is here?

Andy

Sign in to reply to this post

Jason ByrnesWebAssist

use quotes

Sign in to reply to this post

The Flying Fox

Thank you I wasn't too sure but I did think that I should.

Better to check though

Andy

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome.

Sign in to reply to this post

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...