diff --git a/classes/gateways/class-wc-cod.php b/classes/gateways/class-wc-cod.php index e7f9fa3f9eb..9e4a5fe53d4 100644 --- a/classes/gateways/class-wc-cod.php +++ b/classes/gateways/class-wc-cod.php @@ -77,13 +77,25 @@ class WC_COD extends WC_Payment_Gateway { // Process the payment function process_payment ($order_id) { global $woocommerce; - $order = new woocommerce_order ($order_id); + + $order = new WC_Order( $order_id ); + + // Mark as on-hold (we're awaiting the cheque) $order->update_status('on-hold', __('Payment to be made upon delivery.', 'woocommerce')); - $woocommerce->cart->empty_cart(); // Dump the cart - unset($_SESSION['order_awaiting_payment']); // Lose our session - return array( // Return and let's visit the order completed page + + // Reduce stock levels + $order->reduce_order_stock(); + + // Remove cart + $woocommerce->cart->empty_cart(); + + // Empty awaiting payment session + unset($_SESSION['order_awaiting_payment']); + + // Return thankyou redirect + return array( 'result' => 'success', - 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(get_option('woocommerce_thanks_page_id')))) + 'redirect' => add_query_arg('key', $order->order_key, add_query_arg('order', $order_id, get_permalink(woocommerce_get_page_id('thanks')))) ); } diff --git a/readme.txt b/readme.txt index 97a3ae4a65a..ce8bd3b5afd 100644 --- a/readme.txt +++ b/readme.txt @@ -161,6 +161,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Download permissions fix * Billing email sets user email address * Other profile fields filled in based on billing info +* COD reduce stock = 1.5.1 - 08/03/2012 = * Persistent (logged-in) customer carts (thanks dominic-p)