From 1a84463183681cf06a84dd4fcb94988cbd659889 Mon Sep 17 00:00:00 2001 From: Geert De Deckere Date: Wed, 14 Mar 2012 14:34:06 +0100 Subject: [PATCH] Got the basics working. Still needs support for product variations. --- woocommerce-functions.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/woocommerce-functions.php b/woocommerce-functions.php index 9fe86b492e2..40437ec9bd0 100644 --- a/woocommerce-functions.php +++ b/woocommerce-functions.php @@ -725,13 +725,16 @@ function woocommerce_order_again() { // Make sure the previous order belongs to the current customer if ( $order->user_id != $user_id ) return; - // TODO: Copy products from the order to the cart - - if ( 'TODO: everything done' ) { - $woocommerce->add_message( __('We filled your cart with the items of your previous order.', 'woocommerce') ); - wp_safe_redirect( $woocommerce->cart->get_cart_url() ); - exit; + // Copy products from the order to the cart + foreach ( $order->get_items() as $item ) { + // TODO: variation data + $woocommerce->cart->add_to_cart( $item['id'], $item['qty'], $item['variation_id'] ); } + + // Redirect to cart + $woocommerce->add_message( __('We filled your cart with the items of your previous order.', 'woocommerce') ); + wp_safe_redirect( $woocommerce->cart->get_cart_url() ); + exit; } /**