Skip to content

Instantly share code, notes, and snippets.

@attilabacso
Created April 18, 2017 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save attilabacso/ffb2cc7811c0512cc3f153cbd88c5bff to your computer and use it in GitHub Desktop.
Save attilabacso/ffb2cc7811c0512cc3f153cbd88c5bff to your computer and use it in GitHub Desktop.
<?php
//Set minimum order amount
function minimum_order_func(){
global $woocommerce;
if (is_checkout()){
$minorder = 1500;
// If the cart is empty and the order_total less than $minorder (1500)
if ( ($woocommerce->cart->subtotal < $minorder) && (WC()->cart->get_cart_contents_count() <> 0)){
wc_add_notice( sprintf(__('Sorry, you have not met the minimum order amount of ' .$minorder.' HUF'), 'woocommerce'), 'error' );
wp_redirect( get_permalink( woocommerce_get_page_id( 'cart' ) ) );
exit;
}
}
}
add_action('the_post','minimum_order_func',10);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment