You are here

function commerce_cop_payment_save in Commerce Custom Offline Payments 7

Delete a checkout payment.

Parameters

array $payment:

2 calls to commerce_cop_payment_save()
commerce_cop_edit_payment_form_submit in ./commerce_cop.admin.inc
_state
commerce_custom_offline_payment_features_revert in ./commerce_custom_offline_payment.features.inc
Implements hook_features_revert().

File

./commerce_cop.module, line 405
Custom offline payment methods for Drupal Commerce.

Code

function commerce_cop_payment_save($payment, $skip_reset = FALSE) {
  if (!isset($payment['id'])) {
    $payment['id'] = $payment['id'];
  }
  $counter = db_query('SELECT 1 FROM {commerce_custom_offline_payment} WHERE id = :id', array(
    ':id' => $payment['id'],
  ));
  $counter = $counter
    ->fetchColumn();
  if ($counter) {
    $payment_record = drupal_write_record('commerce_custom_offline_payment', $payment, array(
      'id',
    ));
  }
  else {
    $payment_record = drupal_write_record('commerce_custom_offline_payment', $payment);
  }

  // Clear the necessary caches.
  if (!$skip_reset) {
    entity_defaults_rebuild();
    rules_clear_cache(TRUE);
  }
  return $payment_record;
}