Advertisement
majeedraza

WooCommerce - Limit stock shown to customers

Nov 18th, 2016
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2.   // limit stock shown to the customer
  3.   // code goes in functions.php for your child theme
  4.   // in this code, customer will be shown 50 in stock even if there are 1000 in stock.
  5.   // if less than 50, customer will be shown actual stock
  6.   // Dashboard shows correct stock
  7.   add_filter( 'woocommerce_get_stock_quantity', 'limit_stock_shown');
  8.   function limit_stock_shown( $count) {
  9.     if ( !is_admin() ) {
  10.      $count = min( $count, 50 );
  11.     }
  12.     return $count;
  13.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement