Created
October 18, 2017 16:48
-
-
Save codelion7/09b38ac731d58873623303f25ed71161 to your computer and use it in GitHub Desktop.
Add a filter to the product limit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Allowed WooCommerce Post Types | |
* | |
* @return bool | |
* @since 1.2.0 | |
* @author Andrea Grillo <[email protected]> | |
*/ | |
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