Ticket Success - Nonprofit Storytelling Conference

Ticket Success

[insert_php]

## CONFIG
$eventName = “2018 Nonprofit Storytelling Conference”;
$prodSubCat = 22; // The Category of products you put your events in
$nameofevent = “_NameofEvent”; // Name of custom field event name is stored in
$ticketbuyer = “_TicketBuyer”; // Name of custom field the ticket buyer’s name is stored in
$urlforticketreg = “_URLForTicketRegistration”; // Name of custom field for ticket reg URL
$statusTicketsAllocated = 2084; // Tag ID for tickets allocated
$triggerTicketsAllocated = 2090; // Tag ID for triggering tickets allocated
$triggerTicketsNotAllocated = 2086; // Tag ID for tickets not allocated
$triggerVicariousPurchase = 2088; // Tag ID for tickets vicariously purchased
$supportEmail = “support@nonprofitstorytellingconference.com”;

## END CONFIG ##
### Don’t touch anything below this line unless you know what you’re doing

if ($_SERVER[‘SERVER_PORT’] == “443”) { $http = “https://”; } else { $http = “http://”; }
$page = explode(“?”,$_SERVER[‘REQUEST_URI’]);
$pageurl = $http.$_SERVER[‘HTTP_HOST’].$page[0].”?orderId=”.$_GET[‘orderId’].”&inf_field_Email=”.$_GET[‘inf_field_Email’];
global $i2sdk;

if ($_POST){ ### What to do once someone registers their friends
$u = array( $nameofevent => $_POST[‘EventGroup’]);
$cid = $i2sdk->isdk->updateCon((int)$_POST[‘cid’],$u);

for($x=1;$x<=$_POST['qty'];$x++){ $fMap = array("Id"); $c = $i2sdk->isdk->findByEmail($_POST[’email’.$x],$fMap);
if (empty($c)){
$cMap = array(“FirstName” => $_POST[‘first’.$x], “LastName” => $_POST[‘last’.$x],”Email” => $_POST[’email’.$x], “Phone1” => $_POST[‘phone’.$x], “JobTitle” => $_POST[‘jobtitle’.$x]);
$optReason = “Person was registered by “.$_POST[‘buyer’].” for a Box Out event.”;
$c = $i2sdk->isdk->addCon($cMap,$optReason);
$y = $i2sdk->isdk->grpAssign($c,$triggerVicariousPurchase);
$update = array( $nameofevent => $_POST[‘EventGroup’],$ticketbuyer => $_POST[‘buyer’]);
$t = $i2sdk->isdk->updateCon($c,$update);
} else {
$y = $i2sdk->isdk->grpAssign($c[0][‘Id’],(int)$_POST[‘tagId’]);
$update = array( $nameofevent => $_POST[‘EventGroup’],$ticketbuyer => $_POST[‘buyer’], “JobTitle” => $_POST[‘jobtitle’.$x], “Phone1″ => $_POST[‘phone’.$x],”FirstName” => $_POST[‘first’.$x], “LastName” => $_POST[‘last’.$x]);
$t = $i2sdk->isdk->updateCon($c[0][‘Id’],$update);
$y = $i2sdk->isdk->grpAssign($c[0][‘Id’],$triggerVicariousPurchase);
}

}
$s = $i2sdk->isdk->grpAssign((int)$_POST[‘cid’],$triggerTicketsAllocated);
echo “

Excellent!

Your ticket holders have been registered and will be notified by email.

Stay tuned for more exciting information about “.$eventName.”.”;

} else { ### What to show on the success page from the cart

if ($_GET[‘orderId’]) {

#Get Contact INFo
$query = array(“Email” => urldecode($_GET[‘inf_field_Email’]));
$rFields = array(“Id”);
$contact = $i2sdk->isdk->dsQuery(“Contact”,1,0,$query,$rFields);
$cid = $contact[0][‘Id’];

#Check if contact has allocated status tag
$query = array(“ContactId” => $cid, “GroupId” => $statusTicketsAllocated);
$rFields = array(“ContactId”);
$v = $i2sdk->isdk->dsQuery(“ContactGroupAssign”,1,0,$query, $rFields);

if (count($v) < 1) { #Tag purchaser as not yet allocated tickets $s = $i2sdk->isdk->grpAssign($cid, $triggerTicketsNotAllocated);
$cMap = array($urlforticketreg => $pageurl);
$u = $i2sdk->isdk->updateCon($cid,$cMap);

#Get Contact name of purchaser
$name = array(“FirstName”,”LastName”,”Email”,”Phone1″,”JobTitle”);
$p = $i2sdk->isdk->loadCon($cid,$name);

$rFields = array(“Id”,”JobTitle”,”ContactId”);
$q = array(“Id” => intval($_GET[‘orderId’]));
$r = $i2sdk->isdk->dsQuery(“Job”,1,0,$q,$rFields);

#Get Order Items & Quantities
$rFields = array(“ProductId”,”Qty”,”ItemName”);
$q = array(“OrderId”=>(int)$_GET[‘orderId’]);
$r = $i2sdk->isdk->dsQuery(“OrderItem”,100,0,$q,$rFields);

foreach ($r as $product){
$rFields = array(“ProductCategoryId”);
$query = array(“ProductId” => $product[‘ProductId’]);
$y = $i2sdk->isdk->dsQuery(“ProductCategoryAssign”,1,0,$query,$rFields);

if (($y[0][‘ProductCategoryId’] == $prodSubCat) && ($product[‘Qty’] > 0)) { ### What to show if the order contains
$qty = $product[‘Qty’];
echo “

Last Step: Register Your Tickets

Please register a ticket for each person for whom you’ve purchased a “.$eventName.” ticket.

Each ticket holder will be notified of the event and sent ticket information.

Please enter the names and information for all the ticket holders, including yourself if desired, in the form below:

“;
echo “

“;
echo “

“;
for($i=1;$i<=$qty;$i++){ if ($i == 1) { $buyer['f'] = $p['FirstName']; $buyer['l'] = $p['LastName']; $buyer['e'] = $p['Email']; $buyer['p'] = $p['Phone1']; $buyer['j'] = $p['JobTitle']; } else { $buyer['f'] = $buyer['l'] = $buyer['e'] = $buyer['p'] = $buyer['j'] = ""; } ?>

Ticket Holder #

“;
$plural = “”; if ($qty>1) {$plural = “s”; }
echo “

“;
echo “

“;
}
} # End Foreach Product
} # End Count < 1 else { echo "

You’re All Set!

It looks like you’ve already allocated your tickets.

If you’d like to change your ticketholders’ names, please email “.$supportEmail.”.”;
}
}
}

[/insert_php]