Advertisement
wclovers

Set default inventory/stock for new product

Jun 16th, 2023 (edited)
874
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. add_filter('wcfm_product_fields_stock', function ($fields, $product_id) {
  2.     // For new product only
  3.     if (!$product_id) {
  4.         if (isset($fields['manage_stock'])) $fields['manage_stock']['dfvalue'] = 'enable';
  5.         if (isset($fields['stock_qty'])) $fields['stock_qty']['value'] = '10';
  6.  
  7.         if ( WCFMu_Dependencies::wcfm_wc_appointments_active_check() ) {
  8.             if ( current_user_can('manage_appointments') ) {
  9.                 if (isset($fields['_wc_appointment_qty'])) $fields['_wc_appointment_qty']['value'] = '10';
  10.             }
  11.         }
  12.     }
  13.     return $fields;
  14. }, 91, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement