Skip to content

Commit

Permalink
Add the how-did-you-hear field to alert email
Browse files Browse the repository at this point in the history
  • Loading branch information
schavery committed Dec 1, 2015
1 parent 6112890 commit ce6a1a6
Show file tree
Hide file tree
Showing 3 changed files with 888 additions and 104 deletions.
8 changes: 7 additions & 1 deletion AsyncSalesforce.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,15 @@ private function update_or_create_donation(&$info) {
// update donation with amount and success.
$this->update_donation($info, $dli);

// we need this for the email:
// we need these for the email:
if(strlen($dli['In_Honor_Of__c']) > 0) {
$info['honor'] = sprintf("In Honor of: %s\n",
$dli['In_Honor_Of__c']);
}

if(strlen($dli['Referred_by__c']) > 0) {
$info['referral'] = $dli['Referred_by__c'];
}

} else {

Expand Down Expand Up @@ -420,7 +424,9 @@ private function send_email(&$info) {
Amount: {$info['amount-string']}
Recurrence: {$info['recurrence-string']}
Email: {$this->contact->Email}
Phone: {$this->contact->Phone}
Location: {$this->contact->MailingCity}, {$this->contact->MailingState}
Referred by: {$info['referral']}
{$info['honor']}
Salesforce Link: https://na32.salesforce.com/{$this->contact->Id}
EOF;
Expand Down
13 changes: 10 additions & 3 deletions UCSalesforce.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ private function merge_contact(&$info) {

// Referral field
if(!empty($info['hearabout'])) {
if(!isset($this->contact->How_did_you_hear_about_Spark__c)) {
$this->contact->How_did_you_hear_about_Spark__c =
ucfirst($info['hearabout']);
$info['referral'] = ucfirst($info['hearabout']);

if(!isset($this->contact->How_did_you_hear_about_Spark__c)) {
$this->contact->How_did_you_hear_about_Spark__c = $info['referral'];
}

// Set referral if it's potentially a contact.
Expand All @@ -138,6 +139,11 @@ private function merge_contact(&$info) {
$this->contact->Referred_By__c = $id;
}
}

// Get the extra data if it's there
if(!empty($info['hearabout-extra'])) {
$info['referral'] .= ': ' . $info['hearabout-extra'];
}
}
}

Expand Down Expand Up @@ -181,6 +187,7 @@ private function create_pending_li(&$info) {
$donation->Type__c = 'Membership';
$donation->Stripe_Status__c = 'Pending';
$donation->Stripe_Id__c = $info['stripe-id'];
$donation->Referred_by__c = parent::string_truncate($info['referral']);

$donation->In_Honor_Of__c =
parent::string_truncate($info['inhonorof'], 64);
Expand Down
Loading

0 comments on commit ce6a1a6

Please sign in to comment.