ec_nap.module

Tracking 6.x-1.x branch
  1. drupal
    1. 6 contributions/nap/modules/ec_nap/ec_nap.module

Functions & methods

NameDescription
ec_nap_disableImplementation of hook_disable().
ec_nap_ec_txn_workflowImplementation of hook_ec_txn_workflow().
ec_nap_enableImplementation of hook_enable().
ec_nap_nap_form_is_productImplementation of hook_nap_form_is_product().
ec_nap_nap_handlerImplementation of hook_nap_handler().

File

View source
  1. <?php
  2. /**
  3. * Implementation of hook_nap_handler().
  4. */
  5. function ec_nap_nap_handler() {
  6. return array(
  7. // The display name of this module.
  8. 'name' => 'Node Access Product for e-Commerce',
  9. // The display name of what we're integrating.
  10. 'integration' => 'e-Commerce',
  11. // The short name of the recurring module (FALSE for none).
  12. 'recurring module' => 'ec_recurring',
  13. // The parent path of the settings page.
  14. 'settings path' => 'admin/ecsettings',
  15. // The parent path of the reports page.
  16. 'reports path' => 'admin/store',
  17. );
  18. }
  19. /**
  20. * Implementation of hook_enable().
  21. */
  22. function ec_nap_enable() {
  23. drupal_load('module', 'nap');
  24. nap_notify('enable', 'ec_nap');
  25. }
  26. /**
  27. * Implementation of hook_disable().
  28. */
  29. function ec_nap_disable() {
  30. drupal_load('module', 'nap');
  31. nap_notify('disable', 'ec_nap');
  32. }
  33. /**
  34. * Implementation of hook_ec_txn_workflow().
  35. */
  36. function ec_nap_ec_txn_workflow($txn, $orig) {
  37. if (ec_store_transaction_workflow('type_code', $txn->workflow) == EC_WORKFLOW_TYPE_COMPLETE) {
  38. // Work out recurring date.
  39. foreach ($txn->items as $i => &$node) {
  40. // Get the expiry date.
  41. if ($node->schedule['expiry']) {
  42. // There is an expiry date.
  43. $node->nap_recurring_date = strftime('%Y-%m-%d %H:%M:%S', $node->schedule['expiry']);
  44. }
  45. else {
  46. // No expiry date.
  47. $node->nap_recurring_date = 0;
  48. }
  49. }
  50. $customer = $txn->customer;
  51. nap_save_purchase($txn->txnid, $customer->uid, $txn->items);
  52. }
  53. }
  54. /**
  55. * Implementation of hook_nap_form_is_product().
  56. */
  57. function ec_nap_nap_form_is_product($form, $form_state, $form_id) {
  58. return ec_product_form_is_product($form_id, $form);
  59. }