$stock_available = new StockAvailable($id_stock_available); PP::setQty($stock_available, $quantity); $stock_available->update(); } else { $out_of_stock = StockAvailable::outOfStock($id_product, $id_shop); $stock_available = new StockAvailable(); $stock_available->out_of_stock = (int) $out_of_stock; $stock_available->id_product = (int) $id_product; $stock_available->id_product_attribute = (int) $id_product_attribute; PP::setQty($stock_available, $quantity); if ($id_shop === null) { $shop_group = Shop::getContextShopGroup(); } else { $shop_group = new ShopGroup((int) Shop::getGroupFromShop((int) $id_shop)); } if ($shop_group->share_stock) { $stock_available->id_shop = 0; $stock_available->id_shop_group = (int) $shop_group->id; } else { $stock_available->id_shop = (int) $id_shop; $stock_available->id_shop_group = 0; } $stock_available->add(); } Hook::exec('actionUpdateQuantity', array('id_product' => $id_product, 'id_product_attribute' => $id_product_attribute, 'quantity' => $stock_available->quantity + $stock_available->quantity_remainder)); } Cache::clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $id_product . '*'); } } StockAvailable::ppInit();