While working on getting recurring donations going with ec_donate, I have found that ec_recurring will only work with a transaction that has items that have a schedule attached to them.

For ec_donate, the transactions have no items, hence ec_recurring won't work. What I suggest is adding another stanza to handle this. It would be located in addition to the code in the ec_recurring_alloc_get_recurring() function in ec_recurring.alloc.inc

if(count($txn->items)==0 && $txn->type=='donation') { // this is a donation transaction
      module_load_include('inc', 'ec_recurring');
      $schedule = ec_recurring_schedule_load($form_state['values']['schedule_id']);
      $recurring = array(
        'name' => $schedule['name'],   
        'start_date' => _ec_recurring_expiry_calc($schedule),
        'price' => $txn->gross,
        'period' => $schedule['numunits'],
        'unit' => $schedule['unit'],
        'repeat' => $schedule['cycles'],
        'description' => 'Donation of ' .$txn->gross. ' recurring every ' .$schedule['numunits']. ' ' .$schedule['unit'],
      );
      return $recurring;

Comments

davea’s picture

The only other way I can see this working is for me to code ec_donate to actually add a single $item to the $txn which seems like a hack.

Thanks,
DaveA

davea’s picture

StatusFileSize
new3.54 KB

I have attached a patch which should address all the needs mentioned above.

Thanks!
Dave

davea’s picture

Gordon,

Can you please commit this patch?

This adds functionality for donations to be recurring without having to run all of ecommerce.

Thanks,
DaveA