Skip to content

Instantly share code, notes, and snippets.

@jasperf
Last active February 16, 2020 09:11
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 jasperf/54af822f7e971d0a68b653bb9e24ecc0 to your computer and use it in GitHub Desktop.
Save jasperf/54af822f7e971d0a68b653bb9e24ecc0 to your computer and use it in GitHub Desktop.
WooCommerce Filter on user role to display minimum quantity of products with https://wordpress.org/plugins/product-quantity-for-woocommerce/
add_filter( 'alg_wc_pq_get_product_qty_min', 'my_product_qty_min_by_user_role', 10, 2 );
function my_product_qty_min_by_user_role( $qty, $product_id ) {
$current_user = wp_get_current_user();
return ( in_array( 'bedrijf', $current_user->roles ) ? 10 : $qty );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment