diff --git a/classes/class-wc-checkout.php b/classes/class-wc-checkout.php index ea1de29305f..d949d5273a8 100644 --- a/classes/class-wc-checkout.php +++ b/classes/class-wc-checkout.php @@ -21,6 +21,7 @@ class WC_Checkout { function __construct () { global $woocommerce; + add_action('woocommerce_checkout_process',array(&$this,'checkout_process')); add_action('woocommerce_checkout_billing',array(&$this,'checkout_form_billing')); add_action('woocommerce_checkout_shipping',array(&$this,'checkout_form_shipping')); @@ -59,6 +60,12 @@ class WC_Checkout { ); $this->checkout_fields = apply_filters('woocommerce_checkout_fields', $this->checkout_fields); } + + /** Checkout process */ + function checkout_process() { + // When we process the checkout, lets ensure cart items are rechecked to prevent checkout + do_action('woocommerce_check_cart_items'); + } /** Output the billing information form */ function checkout_form_billing() { diff --git a/readme.txt b/readme.txt index 08628201456..70f417d5cc9 100644 --- a/readme.txt +++ b/readme.txt @@ -87,6 +87,8 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo * Classes added to my-account * Fix for price filtering when the shop is the homepage * Renamed orderby GET variable to 'sort' to prevent conflicts with permalinks +* Fixed a bug allowing checkout when items are out of stock +* Added a cart item error page for checkout, if the items are invalid = 1.4.2 - 09/02/2012 = * Uninstall fix diff --git a/shortcodes/shortcode-checkout.php b/shortcodes/shortcode-checkout.php index d49728e09f5..5cd5edb29af 100644 --- a/shortcodes/shortcode-checkout.php +++ b/shortcodes/shortcode-checkout.php @@ -21,11 +21,20 @@ function woocommerce_checkout( $atts ) { if (sizeof($woocommerce->cart->get_cart())==0) return; - $non_js_checkout = (isset($_POST['woocommerce_checkout_update_totals']) && $_POST['woocommerce_checkout_update_totals']) ? true : false; - do_action('woocommerce_check_cart_items'); - if ( $woocommerce->error_count()==0 && $non_js_checkout) $woocommerce->add_message( __('The order totals have been updated. Please confirm your order by pressing the Place Order button at the bottom of the page.', 'woocommerce') ); + if ( $woocommerce->error_count()>0 ) { + + woocommerce_get_template('checkout/cart-errors.php'); + + } else { + + $non_js_checkout = (isset($_POST['woocommerce_checkout_update_totals']) && $_POST['woocommerce_checkout_update_totals']) ? true : false; + + if ( $woocommerce->error_count()==0 && $non_js_checkout) $woocommerce->add_message( __('The order totals have been updated. Please confirm your order by pressing the Place Order button at the bottom of the page.', 'woocommerce') ); + + woocommerce_get_template('checkout/form-checkout.php'); + + } - woocommerce_get_template('checkout/form-checkout.php'); } \ No newline at end of file diff --git a/templates/checkout/cart-errors.php b/templates/checkout/cart-errors.php new file mode 100644 index 00000000000..487c90fd919 --- /dev/null +++ b/templates/checkout/cart-errors.php @@ -0,0 +1,13 @@ + + +show_messages(); ?> + +

+ + + +

\ No newline at end of file