4 replies [Last post]
ñull@drupal.org's picture
Offline
Joined: 01/26/2009
Juice: 114
Was this information Helpful?

I try to add text to the existing token [order-payment-method]. I want it to include the variable_get('uc_check_policy', '') when a check was used as payment method. How do you override the existing token_value function to do this?

digitalfrontiersmedia's picture
Offline
Getting busy with the Ubercode.
Joined: 11/08/2008
Juice: 282
Re: How to add text to an existing token?

Might be easier to simply add a new token [check-policy] than to try to override an existing token.

ñull@drupal.org's picture
Offline
Joined: 01/26/2009
Juice: 114
What is wrong with this?

I added this in uc_payment_pack.module:

<?php
/**
* Implementation of hook_token_list().
*/
function uc_payment_pack_token_list($type = 'all') {
   
$tokens['global']['check-policy'] = t('The check policy');
  return
$tokens;
}

/**
* Implementation of hook_token_values().
*/
function uc_payment_pack_token_values($type, $object = NULL) {
  switch (
$type) {
    case
'global':
      if (!empty(
$object)) {
       
$values['check-policy'] = variable_get('uc_check_policy','');
      }
      break;
  }

  return

$values;
}
?>

I see the new token under Global tokens in /admin/store/help/tokens but when I put the token in modules/ubercart/uc_order/templates/customer.itpl.php , it is not replaced, just [check-policy] appears.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: What is wrong with this?

Since it's a "global" token, I think $object will be NULL, which means you shouldn't have the !empty($object) check. Even if $object is something else, you should still return a value for 'check-policy' since it should be available all the time.

ñull@drupal.org's picture
Offline
Joined: 01/26/2009
Juice: 114
Include Check policy in orders and invoices

I uploaded a patch here that seems to work correctly.