[support] custom trigger

Anth malkouna at yahoo.com.au
Wed Dec 1 22:57:57 UTC 2010


It's not that hard to write your own conditions for CA.  I was using 
uc_fees and needed to apply a fee if the card was AMEX, but the only 
condition that was close was if payment was by credit card.  The 
following two functions did it for me, just change your conditions.  
Once the module was enabled the condition was available to CA.

Anthony.

/**
  * Implementation of hook_ca_condition().
  */
function uc_amex_fee_ca_condition() {
   $order_arg = array(
     '#entity' => 'uc_order',
   );

   $fee_arg = array(
     '#entity' => 'fee',
   );

   $conditions['uc_order_condition_uses_amex'] = array(
     '#title' => t("Check an order's payment method is AMEX"),
     '#category' => t('Order'),
     '#description' => t('Returns TRUE if the order uses AMEX.'),
     '#callback' => 'uc_order_condition_uses_amex',
     '#arguments' => array(
       'order' => $order_arg,
       'fee' => $fee_arg,
     ),
   );
   return $conditions;
}

/******************************************************************************
  * Condition Callbacks and 
Forms                                              *
  ******************************************************************************/

function uc_order_condition_uses_amex($order, $fee, $settings) {
   if(!empty($order->payment_details)) {
     if($order->payment_details['cc_type'] == 'American Express') {
       return TRUE;
     }
   }
   return FALSE;
}

On 6:59 AM, Marty Landman wrote:
> I'm working on a site using Ubercart. Users register and then may list 
> an item for sale - after creating the item as a new node.
>
> There's a requirement that the user be sent an email when their item 
> is created on the site but the only trigger - either Drupal or UC I 
> can find that will help me here is "After saving a new post". This 
> works well because the only nodes these users can save are their for 
> sale items; the only problem is that they also create a node - their 
> user profile - when they register for the site. Which generates what 
> turns out to be an ugly looking email to each new user, because it's 
> tailored for a new item listing.
>
> Ideally if I could insert a bit of PHP code into the action it'd be 
> easy to tease out the triggers I want to act on and those I don't. But 
> at this point I'm totally stuck as to how I can proceed.
>
> Marty
>


More information about the support mailing list