Drupal : Send Ubercart PayPal payment to node author

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).

Module Info

name = Ubercart Tweaks
description = Tweaks for Touristing website. Built by Drupal Developer.
dependencies[] = uc_paypal
package = DrupalD
core = 7.x



* @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, '=')
$form['business'][''] = $am__paypal['field_paypal_email_email'];

//When testing paypal as buyer. DO NOT REMOVE comments unless you are testing paypal.
// $form['email'][''] .= '-buyer';

By DrupalD on Tue, 28/02/2017 - 4:15pm

Add comment

Log in or register to post comments

Try GSuite and get 20% discount for first year