You are here

function commerce_gc_transaction_write in Commerce GC 7

Write a new commerce giftcard transaction record. Uses a database transaction to ensure balance integrity.

Parameters

type $coupon_id:

type $amount:

Return value

type

See also

CommerceGCTransactionEntityController::save().

4 calls to commerce_gc_transaction_write()
commerce_gc_add_transaction_action_form_simple_submit in ./commerce_gc.module
commerce_gc_commerce_coupon_final_checkout_validate in ./commerce_gc.module
commerce_gc_commerce_coupon_insert in ./commerce_gc.module
commerce_gc_submit_order_form_giftcard_transactions in ./commerce_gc.module

File

./commerce_gc.module, line 649
Provides Giftcard coupon bundle, Giftcard Transaction entity and basic user interface elements.

Code

function commerce_gc_transaction_write($coupon_id, $amount, $status = 'complete') {
  $values = array(
    'coupon_id' => $coupon_id,
    'amount' => $amount,
    'status' => $status,
  );
  $transaction = commerce_gc_transaction_new($values);

  // Insert record
  commerce_gc_transaction_save($transaction);
  return !empty($transaction->transaction_id) ? $transaction->transaction_id : NULL;
}