julien731

[AS] Limit products on ticket submission

Oct 3rd, 2016
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. add_filter( 'wpas_cf_taxonomy_oredered_terms', 'wpas_limit_products_on_submission' );
  2. /**
  3.  * Remove products from the front-end dropdown on ticket submission
  4.  *
  5.  * In order the filter out products, simply add the product slug in the array within the foreach. If you want to filter
  6.  * terms by something else than the slug, simply replace:
  7.  *     $product->slug
  8.  * by what you need to use (eg. name, term_is, etc).
  9.  *
  10.  * @param array $products Array of term objects
  11.  *
  12.  * @return array
  13.  */
  14. function wpas_limit_products_on_submission( $products ) {
  15.  
  16.     foreach ( $products as $key => $product ) {
  17.         if ( in_array( $product->slug, array( 'my-product-slug' ) ) ) {
  18.             unset( $products[ $key ] );
  19.         }
  20.     }
  21.  
  22.     return $products;
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment