You are here

function basic_cart_entity_insert in Basic cart 8

Same name and namespace in other branches
  1. 8.6 basic_cart.module \basic_cart_entity_insert()
  2. 8.0 basic_cart.module \basic_cart_entity_insert()
  3. 8.2 basic_cart.module \basic_cart_entity_insert()
  4. 8.3 basic_cart.module \basic_cart_entity_insert()
  5. 8.4 basic_cart.module \basic_cart_entity_insert()
  6. 8.5 basic_cart.module \basic_cart_entity_insert()

Implements hook_entity_insert().

File

./basic_cart.module, line 65

Code

function basic_cart_entity_insert(EntityInterface $node) {
  $utility = new Utility();
  if (Utility::isBasicCartOrder($node
    ->bundle())) {
    $get_cart = $utility::getCart();
    $cart = $get_cart['cart'];
    $nid = $node
      ->id();
    basic_cart_order_send_notifications($node);
    $order = new OrderConnectStorage();
    foreach ($cart as $key => $value) {
      $params['oid'] = $nid;
      $params['id'] = $key;
      $params['entitytype'] = $value
        ->getEntityTypeId();
      $params['quantity'] = $get_cart['cart_quantity'][$key];
      $order
        ->insert($params);
    }
    $utility::emptyCart();
  }
}