Enviar notificacion de email al admin con wp-ecommerce.

en /wp-content/plugins/wp-e-commerce/wpsc-includes/purchase-log-notification.class.php
localizar la funcion send() e incluir el codigo

[sourcecode language=»PHP»]
//Correo Admin
//add_filter(‘wp_mail_content_type’,create_function(», ‘return «text/html»;’));
$admin_email = get_option(‘admin_email’);
//$headers[] = ‘From: miweb.es < '.$admin_email.'>‘;
//$headers[] = ‘Cc: John Q Codex ‘;
wp_mail( $admin_email , __( ‘Purchase Report’, ‘wpsc’ ), $this->html_message , $headers );
//Fin Correo Admin [/sourcecode] antes del return.

Despues en el archivo functions de tu tema /wp-content/themes/default/functions.php añade:

[sourcecode language=»PHP»]
//añade direccion de facturacion y envio a los email de notificacion de compra
include («WpscExtendCustEmail.php»);
[/sourcecode]

con el contenido siguiente:

Fuente : https://gist.github.com/webaware/4964078

[sourcecode language=»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»;
//Traduccion
$msg = str_replace(«SHIPPING ADDRESS»,»DIRECCION DE ENVIO»,$msg);
$msg = str_replace(«BILLING ADDRESS»,»DIRECCION DE FACTURACION»,$msg);
// 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»;
//Traduccion
$msg = str_replace(«First name»,»Nombre»,$msg);
$msg = str_replace(«Last name»,»Apellidos»,$msg);
$msg = str_replace(«Street»,»Calle»,$msg);
$msg = str_replace(«City»,»Ciudad»,$msg);
$msg = str_replace(«State»,»Provincia»,$msg);
$msg = str_replace(«Country»,»Pais»,$msg);
$msg = str_replace(«Zip»,»Codigo Postal»,$msg);
$msg = str_replace(«Phone»,»Telefono»,$msg);
}
}
}

return $msg;
}
}

new WpscExtendCustEmail();

[/sourcecode]

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>