2.1.3 Minimum Order Required
-
WordPress 3.8.1 with WooCommerce 2.1.3 on Media Temple gs…
Does anyone know of a tested method to require a minimum order amount for 2.1.3? I am currently using the code snippet below. It does prevent you from accessing the checkout page if your order does not meet the minimum, however, if you do meet the minimum and successfully checkout, you are still redirected back to the cart, which is now empty because the order went through. Before the redirect back to the cart, the site does attempt to load the order-recieved page (endpoint), but the redirect happens before the page loads that has the order confirmation, making the purchaser think their order did not go through when it did.
add_action('the_post','minimum_order_func',10); function minimum_order_func(){ global $woocommerce; if ( is_checkout() ) { $minorder = 150; if( $woocommerce->cart->subtotal < $minorder){ $woocommerce->add_error( sprintf(__('Sorry, you have not met the minimum order amount of $' . $minorder . '. Once you do meet this minimum, you can proceed with the checkout. <a href="%s/store">Continue Shopping →</a>', 'woocommerce'), home_url()) ); wp_redirect( get_permalink( woocommerce_get_page_id( 'cart' ) ) ); exit; } } }
The topic ‘2.1.3 Minimum Order Required’ is closed to new replies.