You are here

function uc_stock_set in Ubercart 8.4

Same name and namespace in other branches
  1. 6.2 uc_stock/uc_stock.module \uc_stock_set()
  2. 7.3 uc_stock/uc_stock.module \uc_stock_set()

Sets the product stock level.

Parameters

string $sku: The product SKU of the stock level to set.

int $qty: The number of items in stock.

1 call to uc_stock_set()
StockTest::testProductStock in uc_stock/tests/src/Functional/StockTest.php
Tests stock settings on product edit page.

File

uc_stock/uc_stock.module, line 99
Allow ubercart products to have stock levels associated with their SKU.

Code

function uc_stock_set($sku, $qty) {
  $connection = \Drupal::database();
  $connection
    ->update('uc_product_stock')
    ->fields([
    'stock' => $qty,
  ])
    ->condition('sku', $sku)
    ->execute();
}