Advertisement
CodeDropz

Change min/max filter on specific product ID"S

Sep 5th, 2024
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. // Set max limit based on product id.
  2. add_filter( 'dndmfu_wc_upload_max', function( $max, $product_id ) {
  3.    
  4.     // List of product ids and limit
  5.     $product_ids = [121 => 10, 120 => 10, 103 => 12, 102 => 6, 101 => 4, 100 => 2];
  6.    
  7.     foreach( $product_ids as $id => $limit ) {
  8.         if ( $product_id === $id ) {
  9.             return $limit;
  10.         }
  11.     }
  12.    
  13.     return $max;
  14. }, 10, 2 );
  15.  
  16. // Set min limit based on product id.
  17. add_filter( 'dndmfu_wc_upload_min', function( $min, $product_id ) {
  18.    
  19.     // List of product ids and limit
  20.     $product_ids = [121 => 1, 120 => 1];
  21.    
  22.     foreach( $product_ids as $id => $minimum ) {
  23.         if ( $product_id === $id ) {
  24.             return $minimum;
  25.         }
  26.     }
  27.    
  28.     return $min;
  29. }, 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement