This CodeLet alter the 'uc_paypal_wps_email' variable when PayPal payment is enabled with Ubercart & sets to node author's PayPal account email address. This requires creating a field on user's account with name 'PayPal Email' (field_paypal_email).
CodeLet
<?php
/**
* @file
*
* @author DrupalD
*/
/**
* Implementation of hook_form_alter
*
* @param unknown $form
* @param unknown $form_state
* @param unknown $form_id
* @author DrupalD
*/
function mymodule_tweaks_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'uc_paypal_wps_form') {
$am__cart = array_values(uc_cart_get_contents());
$sn__uid = $am__cart[0]->uid;
$am__paypal = db_select('field_data_field_paypal_email', 'ppe')
->fields('ppe', array('field_paypal_email_email'))
->condition('entity_id', $sn__uid, '=')
->execute()
->fetchAssoc();
$form['business']['#value'] = $am__paypal['field_paypal_email_email'];
//When testing paypal as buyer. DO NOT REMOVE comments unless you are testing paypal.
// $form['email']['#value'] .= '-buyer';
}
}
?>
Info file details
name = Ubercart Tweaks
description = Ubercart Tweaks. Built by <a href="http://bit.ly/1N7nWf0">Drupal Developer</a>.
dependencies[] = uc_paypal
package = DrupalD
core = 7.x
Modules used