Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Extend WP e-Commerce customer emails to add shipping and billing details. Just drop this into a plugin, or add to your theme's functions.php. Some discussion over at my blog post about extending notification emails in wp-e-commerce -- http://snippets.webaware.com.au/snippets/extend-notification-emails-in-wp-e-commerce/

View gist:4964078
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
<?php
/**
* extend WP e-Commerce customer emails to add shipping and billing details
* drop this into a plugin, or add to your theme's functions.php
*/
class WpscExtendCustEmail {
/**
* add filter hooks
*/
public function __construct() {
add_filter('wpsc_purchase_log_customer_notification_raw_message', array($this, 'customerMessage'), 10, 2);
}
/**
* intercept filter hook for customer notification message
* @param string $msg the customer notification message
* @param WPSC_Purchase_Log_Customer_Notification $log_notification
* @return string
*/
public function customerMessage($msg, $log_notification) {
$purchase_log = $log_notification->get_purchase_log();
$form_data = new WPSC_Checkout_Form_Data($purchase_log->get('id'));
$cust_info = $form_data->get_gateway_data();
foreach ($cust_info as $heading => $section) {
// remove underscores from heading, convert to uppercase, add to message
$heading = strtoupper(strtr($heading, '_', ' '));
$msg .= "\n\n$heading\n" . str_repeat('=', strlen($heading)) . "\n";
// iterate over customer fields
foreach ($section as $label => $value) {
if ($value) {
// if value is a country code, convert it to a country name
if ($label == 'country') {
$value = wpsc_get_country($value);
}
// remove underscores from label, convert first character to uppercase
$label = ucfirst(strtr($label, '_', ' '));
$msg .= "$label: $value\n";
}
}
}
return $msg;
}
}
new WpscExtendCustEmail();

Excellent work, thanks for sharing. Shame you've moved on to Woo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.