You are here

public function LocalStockUpdater::clearLocationStockTransactions in Commerce Stock 8

1 call to LocalStockUpdater::clearLocationStockTransactions()
LocalStockUpdater::updateLocationStockLevel in modules/local_storage/src/LocalStockUpdater.php
Updates the stock level of an entity at a specific location.

File

modules/local_storage/src/LocalStockUpdater.php, line 240

Class

LocalStockUpdater
Class LocalStockUpdater.

Namespace

Drupal\commerce_stock_local

Code

public function clearLocationStockTransactions($location_id, PurchasableEntityInterface $entity, $last_txn) {
  $query = $this->database
    ->delete('commerce_stock_transaction')
    ->condition('location_id', $location_id)
    ->condition('entity_id', $entity
    ->id())
    ->condition('entity_type', $entity
    ->getEntityTypeId())
    ->condition('id', $last_txn, '<=');
  $result = $query
    ->execute();
  return $result;
}