Formal and informal German translations - thanks to stefahn, jessor, Ramoonus , owcv and deckerweb

* Hook for checking cart contents during cart/checkout - used for plugins too
This commit is contained in:
Mike Jolley 2011-11-09 17:26:45 +00:00
parent 1b9b1ea2cc
commit 67779afd3f
5 changed files with 18 additions and 25 deletions

View File

@ -45,6 +45,8 @@ class woocommerce_cart {
$this->applied_coupons = array();
$this->get_cart_from_session();
if ( isset($_SESSION['coupons']) ) $this->applied_coupons = $_SESSION['coupons'];
add_action('woocommerce_check_cart_items', array(&$this, 'check_cart_items'), 1);
}
/**
@ -540,6 +542,17 @@ class woocommerce_cart {
if ( $this->total > 0 ) return true; else return false;
}
/**
* Check cart items for errors
*/
function check_cart_items() {
$result = $this->check_cart_item_stock();
if (is_wp_error($result)) $woocommerce->add_error( $result->get_error_message() );
}
/**
* looks through the cart to check each item is in stock
*/

View File

@ -677,24 +677,8 @@ class woocommerce_checkout {
'item_meta' => $item_meta->meta
), $values);
// Check stock levels
if ($_product->managing_stock()) :
if (!$_product->is_in_stock() || !$_product->has_enough_stock( $values['quantity'] )) :
$woocommerce->add_error( sprintf(__('Sorry, we do not have enough "%s" in stock to fulfil your order. Please edit your cart and try again. We apologise for any inconvenience caused.', 'woothemes'), $_product->get_title() ) );
break;
endif;
else :
if (!$_product->is_in_stock()) :
$woocommerce->add_error( sprintf(__('Sorry, we do not have enough "%s" in stock to fulfil your order. Please edit your cart and try again. We apologise for any inconvenience caused.', 'woothemes'), $_product->get_title() ) );
break;
endif;
endif;
// Check cart items for errors
do_action('woocommerce_check_cart_items');
endforeach;

View File

@ -107,6 +107,7 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo
* Directory changed for uploading file downloads - uploads/woocommerce_files
* Download directory created on install as well as htaccess for denying access
* Formal and informal German translations - thanks to stefahn, jessor, Ramoonus , owcv and deckerweb
* Hook for checking cart contents during cart/checkout - used for plugins too
= 1.2 - 03/11/2011 =
* Added quick status change buttons (processing/complete) to orders panel

View File

@ -62,10 +62,7 @@ function woocommerce_cart( $atts ) {
endif;
$result = $woocommerce->cart->check_cart_item_stock();
if (is_wp_error($result)) :
$woocommerce->add_error( $result->get_error_message() );
endif;
do_action('woocommerce_check_cart_items');
$woocommerce->show_messages();

View File

@ -30,9 +30,7 @@ function woocommerce_checkout( $atts ) {
$woocommerce_checkout->process_checkout();
$result = $woocommerce->cart->check_cart_item_stock();
if (is_wp_error($result)) $woocommerce->add_error( $result->get_error_message() );
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.', 'woothemes') );