Skip to content

Instantly share code, notes, and snippets.

@codelion7
Created October 18, 2017 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codelion7/09b38ac731d58873623303f25ed71161 to your computer and use it in GitHub Desktop.
Save codelion7/09b38ac731d58873623303f25ed71161 to your computer and use it in GitHub Desktop.
Add a filter to the product limit
/**
* Allowed WooCommerce Post Types
*
* @return bool
* @since 1.2.0
* @author Andrea Grillo <andrea.grillo@yithemes.com>
*/
public function vendor_can_add_products( $vendor, $post_type ){
$enable_amount = 'yes' == get_option( 'yith_wpv_enable_product_amount' ) ? true : false;
if( $enable_amount && 'product' == $post_type ){
$products_limit = get_option( 'yith_wpv_vendors_product_limit', 25 );
$products_limit = apply_filters( 'yith_wcmv_products_limit', $products_limit, $vendor );
$products_count = count( $vendor->get_products( array( 'post_status' => 'any' ) ) );
return $post_type === 'product' && $vendor->is_valid() && $vendor->has_limited_access() && $products_limit > $products_count;
}
else {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment