You are here

function commerce_cps_entity_delete in Commerce Cart Pane 7

Implements hook_entity_delete().

File

modules/shipping/commerce_cps.module, line 128

Code

function commerce_cps_entity_delete($entity, $type) {

  // use this hook when line item has been deleted.
  // Use cases:
  // * on Cart form after changing Quantity to 0 and clicking
  // "Update cart" button or by clicking on "Remove" button.
  if ($type == 'commerce_line_item') {
    $bundle = $entity->type;
    $product_types = commerce_product_types();
    $product_types = array_keys($product_types);
    if (in_array($bundle, $product_types)) {
      global $user;
      $cart_order = commerce_cart_order_load($user->uid);
      commerce_cps_add_order_shipping($cart_order);
    }
  }
}