Hello Ubercart rockstars,
I am trying to track down a bug, and don't think there was any way around NOT having to modify the uc_payment.module to fix my issue. Basically what is happening is I am trying to create a custom payment module that adds some of the order information in the order review for the email that is sent to the person who purchased the item. As it is designed this is done by providing the string to be used for the token order-payment-method, which is added to the template files for the invoices / emails. What this means is that the module developers need to customize this string using the following code...
<?php
/**
* Implementation of hook_payment_method().
*/
function uc_custom_payment_method() {
$methods[] = array(
'id' => 'custom',
'name' => t('Custom Payment Method'),
'title' => t('Custom Payment Method'),
'desc' => t('A custom payment method.'),
'callback' => 'uc_payment_method_custom',
'weight' => 1,
'checkout' => FALSE,
'no_gateway' => TRUE,
'review' => 'My custom payment review', /* This gets added to the token order-payment-method */
);
return $methods;
}
?>
This is cool, but this does not allow for much flexibility because I cannot add any Order information along with that review, which is what I need. A better solution would be to give the plugin developer the option to either provide a string OR a function where you then send the order object to that function, like the following...
<?php
/**
* Implementation of hook_payment_method().
*/
function uc_custom_payment_method() {
$methods[] = array(
'id' => 'custom',
'name' => t('Custom Payment Method'),
'title' => t('Custom Payment Method'),
'desc' => t('A custom payment method.'),
'callback' => 'uc_payment_method_custom',
'weight' => 1,
'checkout' => FALSE,
'no_gateway' => TRUE,
'review' => 'uc_custom_review', /* Just call this callback to get the contents of the order-payment-method string */
);
return $methods;
}
function uc_custom_review( $order ) {
// Yay!! I can add order information along with the payment method review.
return 'My order number is ' . $order->order_id;
}
?>
The change to the uc_payment.module that allows for this while at the same time preserve reverse compatibility is given in the attached patch file. Please consider putting this in the next version.
Thanks for your time.
Travis Tidwell
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | uc_payment.patch | 3.13 KB | travist |
| uc_payment.patch | 726 bytes | travist |
Comments
Comment #1
univate commentedComment #2
travist commentedHere is the latest patch. I believe this takes care of all instances of the "review" hook.
Comment #3
longwaveIt's easier to provide your own token or just edit the order templates to achieve this.