daily pastebin goal
68%
SHARE
TWEET

WooCommerce - Limit stock shown to customers

lorro Nov 18th, 2016 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top