You are here

function commerce_registration_delete_lineitem_registration in Commerce Registration 7.2

Action callback.

Deletes all registrations on an order for a given line item.

Related topics

File

./commerce_registration.rules.inc, line 220
Commerce Registration rules file.

Code

function commerce_registration_delete_lineitem_registration($lineitem) {
  $wrapper = entity_metadata_wrapper('commerce_line_item', $lineitem);
  $order = $wrapper->commerce_order
    ->value();
  if (in_array($wrapper->type
    ->value(), commerce_product_line_item_types())) {
    $product = $wrapper->commerce_product
      ->value();
    $line_item_id = $wrapper->line_item_id
      ->value();
    $key = $line_item_id . 'prod-' . $product->sku
      ->value();
    if (isset($order->data['register_entities']) && isset($order->data['register_entities'][$key])) {
      unset($order->data['register_entities'][$key]);
    }
  }
  commerce_order_save($order);
}