Minimum Purchase for WooCommerce


Plugin Description

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

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 minimum 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

Tutorials

.

Set Up a Basic Minimum Purchase Rule

How does the rule choose what to look at in the cart? [Search Criteria]

  • By Role/Membership

(all other possible criteria available in the Pro Plugin)

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. Roles can also be used to associate a user with a pricing level. Use a role management plugin like User Role Editor to establish custom roles, which you can give to a user or class of users. Then you can associate that role with a Minimum Purchase Rule. So when the user logs into your site, their Role interacts with the appropriate Rule.

How is the rule applied to the cart search results? [Rule applied to]

  • All – work with the total of the units/prices
  • Each – apply the rule to each product in the Rule Population
  • Any – Same as each, but limits the rule testing to the first X number of products

Does the Rule apply to Units Quantity amount or Price amount?

  • Units Quantity Amount
  • Price Amount

Here’s a sample of a minimum purchase rule:

  • If the purchaser is a Subscriber - [search criteria:Subscriber]
  • The minimum total for all purchases - [rule applied to: all]
  • Must be greater than $20. - [price amount: $20]

Set Up a 'Cart Contents' Rule

Use Cart Search Criteria of 'Not Logged In'

  • in Cart Search Criteria Box
  • in membership List by Role Box
  • Select 'Not logged in (just visiting)'

With this set up, the rule will act as if it were an 'Apply to all products in the cart' selection, for any customer who is not logged in. This will be very useful, as many stores do not require a login to make a purchase. Equally, similar rules can be set up for specific roles.


Documentation

Minimum 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 minimum 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 Minimum 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 Minimum Purchase Error Message (Pro Only)

This (Pro Only) option allows the display of Minimum 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 Minimum 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 minimum 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/minimum-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 Minimum 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




32 Responses to Minimum Purchase for WooCommerce


  1. Franco

    Hello locally but the plugin does it work?

  2. Looking to preset the quantity on the product page. So default for Product A could be 10x £6/product = £60 total

    Or Product B could be 20x £15/product = £300 total

    Is this something you can do?

    Thanks

    Elliot


    • admin

      Hi Elliot,
      Thanks for your query. The functionality you’re talking about has to do with product presentation and grouping. There are a couple of established ways to handle that in Woo Land. Pricing Deals would pick up the established product grouping you are describing and allow you to deal price it on the fly.
      Best,
      Vark


  3. Kim

    I am looking to set a minimum product price and then anything more would be $2 each. For example:

    10 Products = $30
    14 Products = $30
    20 Products = $40

    Does this do that?

    Thanks,
    Kim.


    • admin

      Hi Kim,
      It sounds like you’re asking if the plugin does 2 different kinds of actions – set a limit, and offer addative pricing (base price plus $2/item after minimum reached). If my understanding of your question is correct, then the answer is no.

      The plugin sets a minimum purchase quantity or $$ amount within the group you wish to act on. Pricing is not updated by the plugin, simply interrogated and assessed.
      Best,
      Vark

  4. Добавьте пожалуйста российский рубль в пункт выбора валюты. Спасибо


    • admin

      Hi,
      My trusty google translator tells me that you would like the currency sign for russian rubles. With the coming upgrade, all of the VarkTech plugins will be looking to the parent plugin (in this case woo) for the currency sign. In the meantime, a quick and dirty change will do the trick. In core/vtmin-apply-rules.php, line 537, change ‘& # 3 6 ;’ [remove all the spaces] to be ‘RUB’ or whatever the the desired rubles currency sign is. Then in the Options page, choose ‘USD’, but it will actually show ‘RUB’ or whatever you set it to.
      Vark


  5. Fossil

    Hi,

    I’m looking to apply minimum orders for some of my products, dependent on the cart price.

    Example: I have a product “wood”, which will have no minimum quantity (you can buy “1″). Another product is “matches”, which would have a minimum order of “20″ if purchased on its own. But if a customer buys “wood & matches”, there is no minimum order on matches, as the cart total is high enough.

    Is this possible? Do I need the pro version?

    Thanks,
    Fossil.


    • admin

      Hi Fossil,
      Thanks for your query. What you want is definitely possible, but you will need the pro version.
      Best,
      Vark

  6. Hello,

    I was wondering, is there a way to have a incremental minimum value?

    I mean, I have a minimum buy of 100 itens, but after that i want only increments of 50, so it could only be 100, 150, 200 etc


    • admin

      Hi Gabriel,
      The plugin won’t do this out of the box, but with a bit of judicious customization, it will do the job…
      Vark

  7. Hi Vark,
    On my Woocommerce cart page, I’ve ridded myself of the shipping options in lieu of adding shipping items to the page directly. (Put something in your cart and proceed to checkout to see what I mean. No signin necessary)

    What I need to do is to disallow a completed purchase until at least one of the above items is clicked on. Will this plug-in do that/ And if not, will the pro? I guess I would need to have an either/or option within the plugin. Something like ‘can’t be completed until you choose item 4567 or 4568 or 4569 or 4570″

    Is this possible?

    Thanks,
    Patrick


    • admin

      Hi Patrick,
      Yes, the pro version of the plugin will do this for you. Once the pro version is purchased and installed, one way to do it would be to create a Minimum Purchase custom category for these four products only. Then create a min purch rule, saying that for every cart, a min purch of 1 unit for this custom category must be satisfied.
      Best,
      Vark

  8. Vark,

    Firstly pardon my ignorance. When I get the message that a minimum purchase condition wasn’t met, all I get is box containing “Minimum Purchase error found” no details of just what it was or how to remedy the problem, I’m sure a customer would get very peeved off by that very quickly.

    So my question is, just where and how do I remedy that problem so it shows the sort of detail that is in your tutorial videos.

    Kindest Regards
    Paul Cade


    • admin

      Hi Paul,
      The custom error messages produced by the plugin use JS injection to place the messages on the screen. There are two quick things to check:
      (1) JS conflict.
      (2) Go to the setup options page, check the following:
      (a) on of “Show Error Messages Just Before Checkout Products List” or “Show 2nd Set of Error Messages at Checkout Address Area” must be set to ‘yes’
      (b) the HTML Selector matching the switches from (a) **are set to actual selectors available in your theme**

  9. My client would like a customer to “fill a shipping container with products” before they can checkout. We have a specific equation that calculates the length and width of each item to calculate its capacity. Once the capacity is met the customer can check out. Is this something that would work with this plugin? Thank you!


    • admin

      Hiya,
      It would take a bit of customization to make the two systems work together. Essentially you would set up a normal rule, then write some custom code to override that rule to use your shipping container algorithm.
      Best,
      Vark

  10. Hi, if I set up my min total order at $25, but we got a product we’ll call it X who got a huge discount on it but 2 conditions may apply: 1) Costumers can only buy one by order AND when that product X is on your cart, your minimum order will increase automatically to $50. Can you do that?


    • varkadmin

      Hi,
      Thanks for the query. The plugin won’t do that functionality out of the box, there would have to be some customization.
      Thanks,
      Vark


  11. Den

    After the activating plugin – encoding error (throughout the site)


    • Den

      Notice: Undefined index: HTTPS in /home/xxxxxx/xxxxxx/docs/wp-content/plugins/minimum-purchase-for-woocommerce/woo-integration/vtmin-parent-cart-validation.php on line 156

      charset error on wp-admin and on the site

      example Описание


      • admin

        Hi,
        I believe you’ll need an upgrade slated for the next version of the plugin.

        In minimum-purchase-for-woocommerce/woo-integration/vtmin-parent-cart-validation.php,
        Please replace lines 154-164 (replace function vtmin_currPageURL) with the following:

        /* ************************************************
        ** Application – get current page url
        *
        * The code checking for ‘www.’ is included since
        * some server configurations do not respond with the
        * actual info, as to whether ‘www.’ is part of the
        * URL. The additional code balances out the currURL,
        * relative to the Parent Plugin’s recorded URLs
        *************************************************** */
        public function vtmin_currPageURL() {
        global $vtmin_info;
        $currPageURL = $this->vtmin_get_currPageURL();
        $www = ‘www.’;

        $curr_has_www = ‘no’;
        if (strpos($currPageURL, $www )) {
        $curr_has_www = ‘yes’;
        }

        //use checkout URL as an example of all setup URLs
        $checkout_has_www = ‘no’;
        if (strpos($vtmin_info['woo_checkout_url'], $www )) {
        $checkout_has_www = ‘yes’;
        }

        switch( true ) {
        case ( ($curr_has_www == ‘yes’) && ($checkout_has_www == ‘yes’) ):
        case ( ($curr_has_www == ‘no’) && ($checkout_has_www == ‘no’) ):
        //all good, no action necessary
        break;
        case ( ($curr_has_www == ‘no’) && ($checkout_has_www == ‘yes’) ):
        //reconstruct the URL with ‘www.’ included.
        $currPageURL = $this->vtmin_get_currPageURL($www);
        break;
        case ( ($curr_has_www == ‘yes’) && ($checkout_has_www == ‘no’) ):
        //all of the woo URLs have no ‘www.’, and curr has it, so remove the string
        $currPageURL = str_replace($www, “”, $currPageURL);
        break;
        }

        return $currPageURL;
        }
        public function vtmin_get_currPageURL($www = null) {
        global $vtmin_info;
        $pageURL = ‘http’;
        //if ($_SERVER["HTTPS"] == “on”) {$pageURL .= “s”;}
        if ( isset( $_SERVER["HTTPS"] ) && strtolower( $_SERVER["HTTPS"] ) == “on” ) { $pageURL .= “s”;}
        $pageURL .= “://”;
        $pageURL .= $www; //mostly null, only active rarely, 2nd time through – see above

        //NEVER create the URL with the port name!!!!!!!!!!!!!!
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
        /*
        if ($_SERVER["SERVER_PORT"] != “80″) {
        $pageURL .= $_SERVER["SERVER_NAME"].”:”.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
        } else {
        $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
        }
        */
        return $pageURL;
        }


    • Den

      thank you very much that solved the problem with the encoding


  12. Stripboek

    Hi Vark,
    I also need to translate the errors. Could you send me a basic PO file? I have tried it, but i got erors or it didnt work. I only use the plugin to have a minimum total amount in the checkout.
    Thanks in advance.

    (i posted this also in the other plugin, but it was intended for this plugin) Sorry for my mistake.


  13. Lucimar

    Hello, how can I add the currency BRL – R $?


    • admin

      Hi Happy holidays. If you need the BRL currency, I can send you the code to add to the plugin, with instructions.
      Best,
      Vark


  14. Lu

    I was wondering how do I edit the CSS and text inside the error message? I do not see some sort of templates folder except two CSS folders..

    Also, when the error message pops up, I am still able to click on “Check Out”. Is there a way to disable the checkout button or have it redirect to the cart page?

    Thank you!


    • varkadmin

      Hi,
      You can override the CSS using a setting on the settings page, where you supply overrides directly. There’s currently no way to override the message with a custom message, but that’s in the works. Clicking checkout when you have a Min Purchase error will automatically return you to the checkout, with a repeat of the error message.
      Vark

  15. Hello,
    Just wondering how I could change the error message “Error => Minimum Purchase total of £10.20 required for this group.” if too little a quantity is selected, I tried changing it to “You must purchase a minimum of 6 bottles (£10.20) to proceed. Sorry for any inconvenience caused.” in the “Custom Minimum Purchase Error Message CSS, used at checkout time” area, but nothing has changed. Please help.


    • varkadmin

      Hi,
      You can override the CSS using a setting on the settings page, where you supply overrides directly. There’s currently no way to override the message with a custom message, but that’s in the works.
      Vark

Leave a Comment

Your email address will not be published. Required fields are marked *

*


*