Definition

hook_recurringapi($op, &$obj, $val1 = NULL, $val2 = NULL)
ecommerce-5--4/docs/developer/hooks/core.php, line 310

Description

Implementation of hook_recurringapi().

Parameters

$op Event the hook is reacting to 'on expiry': called when a product has expired 'on purchase': called when a product is purchased 'get previous purchase': called so modules can set the $node->recurring['prevpurchase'] value and override the system default WARNING: Do this with great caution and ensure the format of the value matches that of the default or you'll break the system! 'expiry schedule changed': called when a product schedule has changed 'cron report': called so modules can implement their own reporting code utilizing values in $GLOBALS['expirations']

$obj Reference to data specific to the event 'on expiry': Node of the expired product. In addition to the node fields a $node->expired_schedule member is set to be the row from the ec_recurring_expiration table. NOTE: you must be careful to check the status field of this row before performing operations. The product may be renewed (i.e have a value of ECRECURRING_STATUS_RENEWED) and may not need any additional processing other than setting the status to expired. The system does that automatically. 'on purchase': Transaction 'get previous purchase': Node for the current purchase 'expiry schedule changed': Product node with $node->oldsid set to the previous schedule ID 'cron report': $GLOBALS['expirations'] containing values collected during expiration processing

$val1: First extra value specific to the event 'on expiry': The expiry timestamp 'on purchase': The node ID for the purchased product 'get previous purchase': User ID of the customer 'expiry schedule changed': NULL 'cron report': NULL

$val2: Second extra value specific to the event 'on expiry': NULL 'on purchase': TRUE if this is a renewal of the product 'get previous purchase': NULL 'expiry schedule changed': NULL 'cron report': NULL

Code

<?php
function hook_recurringapi($op, &$obj, $val1 = NULL, $val2 = NULL) {
  switch ($op) {
    case 'on expiry':
      ec_recurring_on_expiry($obj, $val1);
      break;
    case 'on purchase':
      break;
    case 'get previous purchase':
      break;
    case 'expiry schedule changed':
      break;
    case 'cron report':
      // This is intended for use in the cron mail.
      print t("Processed %nprocessed expired products\n%nauto automated payments processed\n\n", array('%nprocessed' => $obj['products_processed'], '%nauto' => $obj['autopay']));
      print t("Processed %nprocessed expired reminders\nSent %nsent reminders\n%nfailed reminders failed\n\n", array('%nprocessed' => $obj['reminders_processed'], '%nsent' => $obj['reminders_sent'], '%nfailed' => $obj['reminders_failed']));
      break;
  }
}
?>