Warning message

Newsletter category Drupal Developer newsletter format has not been set to HTML. There will be no statistics recorded for this newsletter.

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

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'][''] = $am__paypal['field_paypal_email_email'];

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

Dependency

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

Add comment

Log in or register to post comments
QR code for this page URL This page URL
Feedback