Allow other modules to modify transaction details
| Project: | SagePay (former Protx) Direct Payment Gateway for Ubercart |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
I'm working with multiple currencies on a site at the moment and note that this module is pretty rigid in its currency settings (it uses the value set on the config page, which is fair enough). I was about to code in some custom hackwork to check for the existence of my price alteration module but then I thought - wouldn't it be better to just let other modules modify the transaction as and when required?
In Drupal 6 there's this nifty drupal_alter() function which lets you do just that. I've slipped this code in at line 523 of the current release:
<?php
drupal_alter('uc_protx_vsp_direct_transaction', $transaction);
?>Now anyone who wants to make changes can just implement the alter function like so:
<?php
function mymodule_uc_protx_vsp_direct_transaction_alter(&$transaction) {
// Change the transaction object directly, no return value
// EG: $transaction['Currency'] = 'USD';
}
?>I realise this kind of thing is already technically available using the uc_protx_vsp_direct_trigger_txsend Conditional Action trigger, but it's a lot of hassle to implement conditional actions and sometimes you just want a more direct method.

#1
Committed to CVS, thanks for the suggestion. I also passed in $order as the third parameter to drupal_alter so any module can make decisions based on order data if necessary, so your hook implementation should look like this:
<?phpfunction hook_uc_protx_vsp_direct_transaction_alter(&$transaction, $order) {
$transaction['Currency'] = 'USD';
}
?>
#2
Automatically closed -- issue fixed for 2 weeks with no activity.