Viewing 14 replies - 31 through 44 (of 44 total)
  • Mike73 did you ever get an answer to your question?

    There’s several different version of the code here in this posting and all seem radically different from the official documentation here https://docs.woothemes.com/document/minimum-order-amount/

    So before I break everything I’d like to clarify which is correct.

    I have WP 3.6 and WC 2.0.13

    Hi,
    The Minimum Purchase for WooCommerce plugin in www.ads-software.com will do that job for you: https://www.ads-software.com/plugins/minimum-purchase-for-woocommerce/

    Thanks Vark, but I need to get this done with the code. I told my boss I could get this working for him with just the addition of some code and not having to pay for yet another plugin. (At that stage only having seen the “official” documentation).

    We need a blanket minimum amount in the cart which this code covers.

    From what I can tell, only your paid version of the plugin covers that and that has not been budgeted for.

    Hi @petriknz,
    If I understood correctly that you want a whole-store minimum purchase amount, the www.ads-software.com (free) version will give you what you need. As the doc says, just set up a rule for the role ‘not logged in’ or ‘just visiting’ and/or whatever other roles you’d like it to apply to. That will give you full store coverage for that rule. And Bob’s your uncle.

    I’ll have another look at it but when I installed it yesterday the option to have the rules effect the total cart was greyed out if I recall correctly, unless I missed some setting.

    I’m trying to locate your email address on your website to email you regarding another, unrelated, issue I could use assistance with.

    The plugin will work out of the box, no setting changes are needed. Just create a new rule, and it will automatically display the ‘use selection groups’ option. Below, you’ll see a box labeled ‘Membership list by Role’. Just tick the roles you need, in order for the whole store to be covered by the rule.

    My email is: vark [at] varktech.com ..

    Hi All, looks like we have a pretty smart group here, I am having a similar issues, I want to add a small order fee for order less than $50.00. I am halfway there I am currently using

    /* add custom price for small order fee */
    add_action( 'woocommerce_cart_totals_before_shipping', 'cp_check_total' ); 
    
    function cp_check_total() {
    global $woocommerce;
    $minorder = 50.00;
    $excost = 4.95;
    if($woocommerce->cart->get_cart()->cart_contents_total>$minorder) {
        end();
    
     }elseif($woocommerce->cart->get_cart()->cart_contents_total<$minorder) {
    	  $woocommerce->cart->add_fee( 'Small Order Fee', $excost, $taxable = false,'');
    	 }
    
     }

    it is adding the small order fee just fine, but is will add it to all orders regardless of the order total, so even if it is above $50.00 the fee is still added. Any Ideas? Thanks in advance.

    This may fix the problem (Untested, ymmv):

    /* add custom price for small order fee */
    add_action( 'woocommerce_cart_totals_before_shipping', 'cp_check_total' ); 
    
    function cp_check_total() {
      global $woocommerce;
      $minorder = 50.00;
    
      if($woocommerce->cart->get_cart()->cart_contents_total>$minorder) {
          return;
      }
      $excost = 4.95;
      if($woocommerce->cart->get_cart()->cart_contents_total<$minorder) {
      	  $woocommerce->cart->add_fee( 'Small Order Fee', $excost, $taxable = false,'');
      }
    
    }

    hmmmm missed the >= , should be:

    /* add custom price for small order fee */
    add_action( 'woocommerce_cart_totals_before_shipping', 'cp_check_total' ); 
    
    function cp_check_total() {
      global $woocommerce;
      $minorder = 50.00;
    
      if($woocommerce->cart->get_cart()->cart_contents_total>=$minorder) {
          return;
      }
      $excost = 4.95;
      if($woocommerce->cart->get_cart()->cart_contents_total<$minorder) {
      	  $woocommerce->cart->add_fee( 'Small Order Fee', $excost, $taxable = false,'');
      }
    
    }

    Nope still stays for the above $50.00 orders too, maybe I am not using the right hook?

    Hi rsharrer, i have tried to come out something and tested that, it worked for latest version 2.0.13, maybe you can give it a try.

    function woo_add_extra_fee() {
    	global $woocommerce;
    
    	//4 parameters that you can change based on your requirement
    	$extra_fee_label = "Extra Fee";
    	$extra_fee_cost = 5;
    	$extra_fee_taxable = false;
    	$min_order = 50.00;
    
    	//get cart total from session
    	$session_cart = $woocommerce->session->cart;
    	if(count($session_cart) > 0) {
    		$total = 0;
    		foreach($session_cart as $cart_product)
    			$total = $total + $cart_product['line_subtotal'];
    	}
    
    	//if cart total less or equal than $min_order, add extra fee
    	if($total <= $min_order) {
    		$woocommerce->cart->add_fee( __($extra_fee_label, 'woocommerce'), $extra_fee_cost, $extra_fee_taxable );
    	}
    }
    add_action( 'woocommerce_before_calculate_totals', 'woo_add_extra_fee' );

    Terry, it works perfectly. Thank you very much!!

    Ryan, it’s my pleasure and glad to know it worked for you.

    Hi terrytsang, your code looks very good and is almost exactly what I need. How could it be enhanced to also offer a different extra fee and minimum order for BOTH regular and international customers? (i.e. how can you tell if the order is local or international?)

Viewing 14 replies - 31 through 44 (of 44 total)
  • The topic ‘Set a minimum order for cart total?’ is closed to new replies.