Kristian Posted November 14 Share Posted November 14 Hi ! Im trying to make a hook that only lists products in stock in certain category but im sure im missing something. Did any one tried to set up something similar. Code to my hook: use WHMCS\Database\Capsule; add_hook('ShoppingCartProductList', 1, function($vars) { $categoryId = 15; $products = Capsule::table('tblproducts') ->where('category', $categoryId) ->get(); $productsInStock = []; foreach ($products as $product) { if ($product->stockcontrol && $product->qty > 0) { $productsInStock[] = $product; } } $vars['productList'] = $productsInStock; return $vars; }); 0 Quote Link to comment Share on other sites More sharing options...
File_Explorer Posted November 14 Share Posted November 14 (edited) You can edit your orderforms template products.tpl file search for the below: {foreach $products as $key => $product} and add after it and make sure to close the {if} statement and include an else statement so it displays the other products not in this category {if $product.stockControlEnabled === true && $product.qty > 0 && $gid === 15} Edited November 14 by File_Explorer typo 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.