[WP e-Commerce] Minimum order amount

Title of mod: Minimum order amount
Plugin: WP e-Commerce 3.8

Some of payment gateways can not process payments less then 1, 3 or 6$, and for example in our shop we have got products which cost half of dollar… so to protect from that orders which can not be processed by our payment system, we will add small amount filter…

Step 1: Open file „/wp-e-commerce/wpsc-includes/ajax.functions.php” and about line 531 ( inside of the function wpsc_submit_checkout ) add following code:

	if($wpsc_cart->calculate_total_price() < 6) {
		$_SESSION['wpsc_checkout_misc_error_messages'][] = __( 'Not reached the minimum amount of the basket. Minimum is 6$.', 'wpsc' );
		$is_valid = false;

Step 2: Save and upload new file;)

Now, when client will try to finalize order with amount less then our minimum, shopping cart will show him error message „Not reached the minimum amount of the basket. Minimum is 6$.”

15 komentarzy do “[WP e-Commerce] Minimum order amount

  1. Lauren

    Hi melonique – this is a great code thankyou – do you know if it can be applied to create a minimum order per product basis where this can be changed per product? There is a plugin called minimum order but of course it is not compatible with the v3.8 of wp-ecommerce 🙁

  2. meloniq Autor wpisu

    I guess it shouldn’t be too difficult, first You should specify some product meta tag which will hold minimum order e.g. „minimum_order => 3”, then in the same function like in above example foreach all products in cart and check – do they meet the minimum requirements or not, then proceed or show error message.

  3. theanswer

    if((wpsc_cart_item_count() < 3) {
    $_SESSION['wpsc_checkout_misc_error_messages'][] = __( 'Total quantity must be at least 3.', 'wpsc' );
    $is_valid = false;

  4. Bruno

    Hello, is it possible to make this hack when you click on „Add to cart”? I found this function in ajax.functions.php

    if ( $parameters['quantity'] get_remaining_quantity( $product_id, $parameters['variation_values'], $parameters['quantity'] ) > 5 ) {
    $quantity = $wpsc_cart->get_remaining_quantity( $product_id, $parameters['variation_values'], $parameters['quantity'] );
    $cart_messages[] = sprintf( _n( 'Sorry, but there is only %s of this item in stock.', 'Sorry, but there are only %s of this item in stock.', $quantity, 'wpsc' ), $quantity );

    But does not work! Initially was 0…but changing with another number it add to cart..i would like to hack with a number minor of 5

  5. Bruno

    this one sorry

    if ( $parameters['quantity'] <= 5 ) {
    $cart_messages[] = __( 'Sorry, but you cannot add zero items to your cart', 'wpsc' );

    1. meloniq Autor wpisu

      I’m not sure what type of filter You wanna create, but by providen parts of code I guess You want to add as default 5 items into cart?!
      If yes, change line ~28

      $default_parameters['quantity'] = 1;
  6. Gonzalo

    Thanks a lot meloniq! I was about to search which line should I modify, but you saved me a lot of time.
    Thanks again for sharing, cheers!

  7. Gary

    Hi I tried this and nothing happened, no errors but nothing happened. does this not work with the latest versions

    1. meloniq Autor wpisu

      Paste this code:

      if ( $wpsc_cart->calculate_total_price() < 6 ) {
      	$error_messages[] = __( 'Not reached the minimum amount of the basket. Minimum is 6$.', 'wpsc' );
      	$is_valid = false;

      into 'wpsc-includes/ajax.functions.php', wpsc_submit_checkout() function, right before the part wpsc_update_customer_meta( 'checkout_misc_error_messages', $error_messages )

      1. Tina


        This is exactly what I have been looking for but when I paste the code, my site fails to load.
        I’ve been adding the snippet of code before the section that shows as:

        *new code here*
        $error_messages = wpsc_get_customer_meta( 'checkout_misc_error_messages’ );
        if ( ! is_array( $error_messages ) )

        is that right?


      2. Tina

        Sorry – jut realised I was in the wrong area so added just before:

        wpsc_update_customer_meta( 'checkout_misc_error_messages’, $error_messages )

        but still stops site from working?

  8. Zafi

    Hi Guys

    I am looking for something very similar, I am creating website for charity, and all their products are donations, and we want to ensure that there is a minimum donation amount per product that they add to cart, not just over all, is this possible to amend „Add to Cart” function so that it checks the minimum donation amount before adding it to cart.


Dodaj komentarz

Twój adres e-mail nie zostanie opublikowany.

Witryna wykorzystuje Akismet, aby ograniczyć spam. Dowiedz się więcej jak przetwarzane są dane komentarzy.