Min and Max Purchase for WooCommerce


Plugin Description

Min and Max Purchase for WooCommerce (free) allows you to set up minimum and maximum purchase rules for products in your WooCommerce 1.0+ store. Purchases must meet these rules to proceed to checkout payment.

Now with Custom Messaging! You can enter your own custom error message by rule.

In the free plugin, rules search by Role/Membership or 'Not logged in' status.     (see the Pro Plugin for all search options).

If a purchase in your store fails a min and max purchase rule, an error message appears at the top of the checkout page, identifying the error situation and rule requirements. The customer must resolve the error, before the purchase can be completed.

Changelog Info
  • 1.0 - 2013-01-15 * Initial Public Release

Tips and Tricks


All Products in Cart - a Venn Diagram

A diagram representing how the 'all products in cart' search criteria works with the cart itself.


Category Setup and Usage in Search Criteria

Category Setup and Usage in Search Criteria

There's a number of ways to use the Product Category/Min and Max Purchase (Custom) Category structure to your advantage.

  • Use existing Product Category: If you've already got the products grouped in an existing Product Category, use that as your selection group.
  • Create a new Product Category: If the product group you want the rule to apply to will make a useful new Product Category, create it and use that as your selection group.
  • Create a new Min and Max Purchase Category: If the product group you want the rule to apply to crosses existing categories, and a new Product Category would not fit in to your store's structure, create a Min and Max Purchase category and use that as your selection group. Min and Max Purchase categories are only accessed within the min and max purchase system, and have no other affect on your store.
  • Combine using both Product Category and Min and Max Purchase Category: The rule will look for participation in either category as its search criteria.

Creating new Min and Max Purchase Categories and Adding Products to the new Category

A new Min and Max Purchase Category can be created in either the Product page (just under the product category, you'll set the min and max purhcase category box) or in the Rule set page itself. In either location, just click the "+ Add New Min and Max Purchase Category" and name your new category, then add it.

Be sure to add in all the products you want to participate in the new Min and Max Purchase Category. This is done in the same way as product categories, by going to the individual product, and clicking in the appropriate box with the Min and Max purchase category list, and then updating the product.


Role Setup and Usage in Search Criteria

Role Setup

Role/Membership is used within Wordpress to control access and capabilities, when a role is given to a user. Wordpress assigns certain roles by default such as Subscriber for new users or Administrator for the site's owner. New Roles with unique names can be created using a role manager plugin. (As these new new roles are used for search criteria rather than access level, the new roles can have the lowest possible access level.)

Role Usage

Roles have a separate use as well. Think of it as 'logged in as ...' or 'not logged in'. So if a user is 'not logged in', that means the rule applies to anything they buy. Converserly, your store can used the logged in state to separate out tiers of rules. If the user is 'logged in as XXX', any rule with Role XXX in the rule search criteria will be tested against that user's cart contents.

When roles are selected as the sole group criteria, "OR" must be selected in the "And/OR" relationship box just to the left of the Role selection box. Otherwise an error message will be produced, requiring that a category be selected.


Categories and Roles used Together in Search Criteria

Categories and Roles used Together with "and" Selected'

Using Categories and Roles together with "and" selected as rule search criteria, allows similar category criteria to mean different things, depending on the Role. For example, if someone is 'not logged in', the rule can require a min and max of $100 to be purchased for a specific category combination. But if they are logged in with a different role, say as a new role of 'Purchaser', that, one could set up a rule with the same criteria, but require only a $10 min and max purchase.

Categories and Roles used Together with "or" Selected'

Using Categories and Roles together with "or" selected does not add to the rule criteria. Without the role, the category criteria already apply to all roles, so additional role criteria is redundant.


All in Population - Error Message Results

When "all in population" is chosen, the rule acts on the totals of the population found to match the rule search criteria.


Each/Any in Population - Error Message Results

When "each in population" or "any in population" is chosen, the rule acts on each individual product in the population found to match the rule search criteria.


Fix Options Setup Page Problems (Reset to Defaults)

If the options setup is irretrievably messed up, there's an easy fix solution:

  • Take a snapshot of your existing setup, to allow you to recover any settings you'd like from the current setup.
  • Find the "Reset to Defaults" button (just below the "save changes" button)
  • Hit the button and all will be returned to default settings.
  • Re-apply those settings updates you desire.


Show all Internal Data in Debugging Mode

If there are any issues that pop up during testing your Min and Max Purchase rules, you have the option of turning on Debugging Mode. With Debugging Mode on, all of the rule, cart and decision structures used internally during processing are printed to the screen.


Documentation

Min and Max purchase rules are applied at checkout time. They are a tested against the cart contents, and if the purchase fails a rule, an error message is produced. And even if the 'continue to payment button' is selected, checkout won't proceed until the error is resolved.

Plugin Requirements

  • WooCommerce 1.0+
  • WordPress 3.3+
  • PHP 5+

Plugin Options

If a purchase in your store fails a min and max purchase rule, an error message appears at the top of the checkout page, identifying the error situation and rule requirements. The customer must resolve the error, before the purchase can be completed.

Show Error Messages in Table Format

Error message formatting is offered in text style by default (value="no"), and in table format as an option.

Show Error Messages Just Before Checkout Products List

The error message can be show in two places - just before the checkout products list, and just before the checkeout address area. This option sets the error message to display before the products list.

Show Error Messages Just Before Checkout Products List - HTML Selector

For the Product area error message, this option supplies the ID or Class HTML selector this message appears before. This selector would appear in your theme"s checkout area, just above the products display area. Be sure to include the "." or "#" selector identifier before the selector name.
Default value = ".checkout_cart".

Show Error Messages Just Before Checkout Address List

The error message can be show in two places - just before the checkout products list, and just before the checkeout address area. This is the 2nd second option showing the error message, and becomes particularly useful if your theme's checkout is a multi-pane design.

Show Error Messages Just Before Checkout Address List - HTML Selector

For the Address area error message, this option supplies the ID or Class HTML selector this message appears before. This selector would appear in your theme"s checkout area, just above the products display area. Be sure to include the "." or "#" selector identifier before the selector name.
Default value = ".wpsc_checkout_forms".

Show Rule ID in Error Message

There is an option to show the rule id in the error message. This is useful in testing to track error messages back to their originating rule.

Show Product Category Names in Min and Max Purchase Error Message (Pro Only)

This (Pro Only) option allows the display of Product Category names in the error message, if error message criteria is included. This more full explanation of the rule criteria will help the customer resolve any errors.

Show Rule Category Names in Min and Max Purchase Error Message (Pro Only)

This (Pro Only) option allows the display of Min and Max Purchase Rule Category names in the error message, if error message criteria is included. This more full explanation of the rule criteria will help the customer resolve any errors.

Custom Min and Max Purchase Error Message CSS, used at checkout time

There's an option to customize the css of the error message format chosen. Simply place the css in the option field, and it will override the standard css.

Select a Currency Sign

Error message currency sign can be selected from the options available.

Apply More Than 1 Rule to Each Product

Do we apply multiple min and max purchase rules to EACH product in the cart? If not, we apply the FIRST rule we process which applies to a given product. It is ***Strongly Suggested*** that this option be set to "NO", as otherwise the compounding error messages could be quite confusing for the ecommerce customer.

Test Debugging Mode Turned On

The final option turns on the debugging mode. This mode will print to screen all of the structures used in rule testing and error message creation. Only use during testing.


The killer buttons at the bottom of the options screen

Use these buttons wisely. Great to clear out test rules or repair errant structures. Very powerful, handle with care.


Video Tutorials


Installation Instructions

Download and install from WordPress.Org

  1. Use the built-in WordPress plugin installer to download, install and activate the Free version of the plugin hosted at wordpress.org/extend/plugins/min-and-max-purchase-for-woocommerce
  2. Please Note: WooCommerce 1.0 or above is needed to run this plugin successfully.


Tips and Tricks


All Products in Cart - a Venn Diagram

A diagram representing how the 'all products in cart' search criteria works with the cart itself.


Role Setup and Usage in Search Criteria

Role Setup

Role/Membership is used within Wordpress to control access and capabilities, when a role is given to a user. Wordpress assigns certain roles by default such as Subscriber for new users or Administrator for the site's owner. New Roles with unique names can be created using a role manager plugin. (As these new new roles are used for search criteria rather than access level, the new roles can have the lowest possible access level.)

Role Usage

Roles have a separate use as well. Think of it as 'logged in as ...' or 'not logged in'. So if a user is 'not logged in', that means the rule applies to anything they buy. Converserly, your store can used the logged in state to separate out tiers of rules. If the user is 'logged in as XXX', any rule with Role XXX in the rule search criteria will be tested against that user's cart contents.

When roles are selected as the sole group criteria, "OR" must be selected in the "And/OR" relationship box just to the left of the Role selection box. Otherwise an error message will be produced, requiring that a category be selected.


All in Population - Error Message Results

When "all in population" is chosen, the rule acts on the totals of the population found to match the rule search criteria.


Each/Any in Population - Error Message Results

When "each in population" or "any in population" is chosen, the rule acts on each individual product in the population found to match the rule search criteria.


Fix Options Setup Page Problems (Reset to Defaults)

If the options setup is irretrievably messed up, there's an easy fix solution:

  • Take a snapshot of your existing setup, to allow you to recover any settings you'd like from the current setup.
  • Find the "Reset to Defaults" button (just below the "save changes" button)
  • Hit the button and all will be returned to default settings.
  • Re-apply those settings updates you desire.


Show all Internal Data in Debugging Mode

If there are any issues that pop up during testing your Min and Max Purchase rules, you have the option of turning on Debugging Mode. With Debugging Mode on, all of the rule, cart and decision structures used internally during processing are printed to the screen.

Screenshots




36 Responses to Min and Max Purchase for WooCommerce

  1. Can you use this to force them to buy X number or products per category? So they can buy different products but they have to be in the same category.


  2. admin

    Hi Jason,
    Thanks for your query. You can’t do this out of the box with the plugin, but there is a wordpress filter function in the plugin which will allow you to code your specific requirements, per rule.
    Best,
    Vark


  3. Martin

    Its possible limit one product per vendor o something similar? (Sorry my english)


  4. admin

    Hi Martin,
    Don’t really understand the question… perhaps you could compose the question precisely in your language, then run it through google translate…
    Best,
    Vark


  5. sonya

    I need a plugin that will allow products in my shop to be limited to one sale each per user. Can your plugin do this?


  6. admin

    Hi Sonya,
    Thanks for your query. Yes, Min and Max purchase will do that for you, using a Lifetime rule. If each product needs its own individual limit, then each product would need an individual Lifetime rule.
    Best,
    Vark


  7. sonya

    That’s great news, but can i just check, can i set it so every product is included in a ‘rule’, or will I need to create a rule for each individual product separately?

    Thanks


  8. admin

    Hi Sonya,
    No worries. You can actually do it in a single rule. You’d set it up with the following parameters:
    Max purchase limit
    Lifetime purchases
    apply to all products in cart
    Each in population
    qty of 1
    And Bob’s your Uncle!
    Best,
    Vark


  9. sonya

    I can’t begin to tell you how happy I am :) Thank you so much, buying now :)


  10. admin

    Excellent, Thanks! Contact me via the support tabs with any questions.
    Best,
    Vark

  11. Hi, I want to create a sitewide rule stating there is a maximum of 4 products allowed to be ordered in a single transaction.

    I set up a rule but it doesn’t seem to be applying itself. Do I have to check the tick box on each product page that says ‘Min and Max Purchase Category’? or does my single rule apply itself to the whole site automatically?

    Like I say, I want the rue to apply to the whole shop, no matter what category each product is in.

    I’m using the free version of the ‘Min and Max Purchase for WooCommerce’ plugin.

    Thanks


  12. admin

    Hi,
    Thanks for your query. It sounds like another module is conflicting with Min and Max Purchase. A way to test this is to temporarily deactivate all plugins except Woo and Min/max, and also switch to a clean default theme, like 2014. Test. If good, add back 1 module. Retest. Keep adding back one module at a time until the conflict is identified.

    If you’d like 1-on-1 assistance, please contact me through my support channel here: http://www.varktech.com/support/

    Thanks,
    Vark

  13. I want to limit customers to only buying x amount per month. Could I reset the lifetime rule for every costumer every month?


  14. admin

    Hi,
    Thanks for your query. That would work quite well. You could simply go into your PhpMyAdmin and drop the min/max purchase history tables at the end of each month. Then to re-create them, you’d just deactivate and reactivate min/max pro, and the clean new tables would be created.
    Best,
    Vark

  15. hi Sir,
    pre-sales question.

    i am looking forward is using your plugin can we set monthly buying limit for members?


  16. admin

    Hi,
    Thanks for your query. You can use the Lifetime rule function to set a buying limit across time… however, in order to make it a ‘monthly’ function, you would need to clear out the plugin tables which keep track of Lifetime purchases each month. This ‘clearout’ function could either be something you do yourself in phpmyadmin, or you could write a Cron job to do it for you.
    Best,
    Vark

  17. Would you help me to setup Cron Job?


  18. admin

    Hi,
    Sorry, I don’t do consulting work… many places exist to advertise for this, though, and it should be relatively quick and cheap.
    Best,
    Vark

  19. Quick question – It may seem like a simple one but I’m having the darnedest time setting it up with the min/max quantities plugin from woothemes…
    I have a free product called, “Pick-Up Time Slot” that needs to be in a customers cart before they can check out (it specifies the time of day they want to pick up their order).

    Obviously, I only want them to be able to add one of that product., but it’s a variable product (so they can choose from the available time slots), so can I make it so that only 1 Pick-Up time slot can be in their cart but it can be any variation they choose?

    Would I need the pro version to implement any of this?

    Thanks in advance!

    Tali


  20. admin

    Hi,
    I’m a bit confused – you’re asking about the “min/max quantities plugin from woothemes”, which is not my plugin atall… My plugin is this one:
    https://wordpress.org/plugins/min-and-max-purchase-for-woocommerce/
    Assuming for a moment you’re asking about my plugin, the pro version would get you where you need to go….
    Best,
    Vark

  21. I’m looking to modify the plugin so that it fires the warning message when adding a product to the cart. Any developer tips on how this could be accomplished? Have you attempted this before?


  22. admin

    Hi,
    You’d have to change some fairly serious parts of the plugin. In parent-cart-validation.php, you’d have to hook onto to the woo add-to-cart to activate the plugin, and you’d also have to use the Woo admin messaging to pass an error message back to Woo.
    Best,
    Vark

  23. It is not working on my website. I only want customers to be able to purchase less than 30 books. When 31 is in the cart is still lets them complete checkout?


  24. admin

    Hi,
    Thanks for your query. I’m assuming that you created a Max purchase rule of 30. Please try clicking on the actual ‘pay’ button when an error message is present, and you should be prevented from completing the transaction until the error situation is cleared.
    Best,
    Vark


  25. Marcelo

    Is it possible with this plugin to limit the purchase and the amount of products for each different user? For example, one user can buy two products and another user just one.


  26. admin

    Hi,
    Thanks for your query. The short answer is ‘Yes!’. The long answer is: Users are assigned to Roles. You can set up Min/Max rules by Role. If you want to have unique limits by user, each user must have an unique role, and that role can be used to create the user’s unique min/max rule. Roles can be managed using any of a number of WP plugins, such as https://wordpress.org/plugins/user-role-editor/ .
    Best,
    Vark


  27. Marcelo

    Thank you! Thank you so much! Helped me a lot! I’m buying now!

  28. I would like to enquire if the plugin can limit the number of purchase at any one point of time.

    Example, when setting maximum purchase at 3, I will only be able to purchase another item in the future if the item expire or if I cancel it.


  29. admin

    Hi,
    Thanks for your query. Yes, that’s exactly what the plugin is designed to do.
    Let me know if you have any further questions.
    Best,
    Vark

  30. Hi,

    I want to implement a:
    min purchase rule of amount: 2
    max purchase rule of amount: 10

    This will aplly for all product. However I want the customer to see the min purchase amount of 2 (in the add minus button options, whicj is standard set to 1), before clicking on “Buy”, instead of after, like it is set up now.
    I also want the customer to be blocked (if he doesn’t aplly the min/max rule) to continue to the next and final step of the purchase road, which is billing address, payment information.
    I want to apply these rules in different languges, because my website also supports Chinese.

    Can you guys give me tips? Im using the free version.

    regards,
    Frankie


  31. admin

    Hi,
    Thanks for your query. You are asking about a major change in plugin architecture. You’d need to hack the plugin quite a bit to get what you want – you are affecting multiple major areas – when the message is displayed, how the plugin reacts when an error is detected, messaging, multiple languages. A non-trivial series of changes…
    Best,
    Vark


  32. Viviana Gonzalez

    Hola,
    En la compra de este plugin se entregara funcionalidades como, que en la categoria me ponga un valor minimo en el contador del carrito de compras??, si tuviera la funcionalidad de cuanto seria el costo del plugin?


  33. admin

    Hi,
    Thanks for your query. Google translate made a complete hash of your question. Any chance you could ask in English?
    Thanks,
    Vark

  34. Hello Vark,
    I have products that need to be sold in a minimum quantity (like 12 per product) but they can be mixed and matched with colors and size. For instance, you can buy 3 red small, 5 blue medium, 4 gold large (or any other size/color mix as long as you reach 12). Will this plugin allow for that kind of rule?
    Thanks!


  35. admin

    Hi,
    Thanks for the query. The short answer is ‘YES!’. “…any other size/color mix as long as you reach 12″ is fully supported. I also offer rule setup assistance…
    Best,
    Vark

  36. Thank yo so much Vark! This is exactly what I need! And thanks for the speedy reply as well.

    Karen

Leave a Comment

Your email address will not be published.