Definition

hook_ec_transactionapi(&$txn, $op, $a3 = NULL, $a4 = NULL)
ecommerce-5--3/docs/developer/hooks/core.php, line 320

Description

Handle store transaction actions.

Parameters

&$txn A transaction object, passed by reference.

$op A string containing the name of the ec_transactionapi operation. Possible values:

  • "insert": A new transaction is being created. Called by e.g. store_transaction_save(), with $txn an object containing edit fields Standard records in ec_transaction etc. have already been inserted. No return value.
  • "load": A transaction is being loaded from the database. Called by e.g. store_transaction_load(), with $txn containing the transaction loaded so far.
  • "update": A transaction is being updated. Called by e.g. store_transaction_save(), with $txn an object containing edit fields Standard records in ec_transaction etc. have already been updated. No return value.
  • "delete": A transaction is being deleted. The parameter $txn contains all the transaction information, since the standard records in ec_transaction etc. have already been deleted. No return value.
  • "validate": Transaction $txn is being inserted. Argument $a3 contains the section to validate. Errors should be set with form_set_error(). No return value. Called by e.g. store_transaction_validate(), from e.g. Menu: ?q=admin/store with $_POST['op'] == [ t('Update transaction') or t('Create new transaction') ] on submission of a form to create a new transaction or update an existing transaction.
$a3 Additional argument, depending on $op.
  • For "validate", this is the section to validate, in upper case. Possible values include:
    • 'OVERVIEW':
    • 'ADDRESSES':
    • 'ITEMS':
    • 'ALL' (default): Validate all sections.
$a4 Additional argument, depending on $op. (Not currently used?)

Return value

The returned value of the invoked hooks, depending on $op.

  • The "load" operation should return an associative array of "property => value" pairs to be merged in to the loaded transaction object. (Note: do not return an object, as you would with hook_load(), since store_invoke_ec_transactionapi() will ignore it)

Code

<?php
function hook_ec_transactionapi(&$txn, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'insert':
      // Empty the cart for this user.
      // Note that user must be logged in at this point.
      cart_empty($txn->uid);
  }
}
?>