Advertisement
sparkweb

FoxyShop - don't show out of stock products

Apr 29th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. //Do Not Show Out of Stock Items (only works for the main product - not variations)
  2. //This should go in your functions.php file
  3. add_filter('foxyshop_setup_product_info', 'my_product_setup', 10, 2);
  4. function my_product_setup($product_array, $product_id) {
  5.     $current_code = $product_array['code'];
  6.     if (isset($product_array['inventory_levels'][$current_code])) {
  7.         if ($product_array['inventory_levels'][$current_code]['count'] <= 0) {
  8.             $product_array['hide_product'] = 1;
  9.         }
  10.     }
  11.     return $product_array;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement