- Support forum for the Maximum Products per User for WooCommerce.
- This topic has 2 replies, 3 voices, and was last updated 4 years, 3 months ago by Tom Anbinder.
-
AuthorPosts
-
May 19, 2020 at 1:22 pm #100401Carlos MendezGuest
Hello:
I have a question about the “Maximum Products per User for WooCommerce” plugin
I’m creating an online store for downloadable products. The products can be downloaded for free but I would like to be able to limit the number of downloads of a single product for a single customer.
That is, the customer can download a product once but can download products that he has not bought before.
Can you do it with this plugin?
A greeting
June 8, 2020 at 6:12 am #100402Carlos JimenezParticipantHello:
I bought the plug-in but I can’t get it to work the way I want it to.
I’ll explain what I want to achieve and send a screenshot with the configuration:
I have an online shop where all products are downloadable and with a price of 0. What I want to achieve is that only registered users can download 3 products monthly and that each product can be downloaded once during that period.However, in the orders it allows to add more than 3 products when they make a purchase.
June 9, 2020 at 6:25 pm #100403Hi Carlos,
Sorry for the late reply.
This can be done with our plugin, however, you will need to: a) add a small PHP snippet to your (child) theme’s functions.php file, and b) assign all your products to some category or tag.
If that’s good enough – here is what you need to do:
1. To limit the total number of products to 3 – as mentioned, you need to assign all your products to some category or tag. After that you need to enable “Per product category” (or “Per product tag”) option in “WooCommerce > Settings > Maximum Products per User > Limits”, and then set “Limit per user” option for that category (or tag) (in “Products > Categories > Your category > Edit”) to “3”.
2. Now to add an additional “one product only” requirement, you will need to add this snippet:
add_filter( 'alg_wc_mppu_check_quantities_for_product', 'my_alg_wc_mppu_limit_all_products_to_one', 10, 3 ); if ( ! function_exists( 'my_alg_wc_mppu_limit_all_products_to_one' ) ) { /** * Sets max quantity for all products to one. */ function my_alg_wc_mppu_limit_all_products_to_one( $is_valid, $core, $args ) { if ( $is_valid ) { $max_qty_all_products = 1; $user_already_bought = $core->get_user_already_bought_qty( $args['product_id'], $args['current_user_id'], true ); if ( ( $user_already_bought + $args['cart_item_quantity'] ) > $max_qty_all_products ) { if ( $args['do_add_notices'] ) { $core->output_notice( $args['product_id'], $max_qty_all_products, $user_already_bought, $args['is_cart'], $args['cart_item_quantity'], 0 ); } return false; } } return $is_valid; } }
Please give it a try and let me know if you have any questions.
-
AuthorPosts
- You must be logged in to reply to this topic.