Home › Forums › WooCommerce Personalized Product Options Manager (PPOM) › Re Order with previous order Personalized selected options and values › Reply To: Re Order with previous order Personalized selected options and values
Hi Najeeb,
There is one filter in woocommerce “woocommerce_order_again_cart_item_data” which executes when you are doing “Order Again”. (you can find it in Woocommerce plugin)
I have tried to overwrite this functionality but it finds that the Personalize option from previous order is not being coming.
have a look at this previous order: https://www.dropbox.com/s/p562dik2u2utnd6/screenshot-localhost-2017-11-14-09-57-15-458.png?dl=0
and I do “Order Again”: https://www.dropbox.com/s/ztdyqvp6teiqiy7/screenshot-localhost-2017-11-14-09-59-56-307.png?dl=0
and I put the above filter to see what is coming for order item: https://www.dropbox.com/s/woszjl1tipfmpm6/screenshot-localhost-2017-11-14-10-11-36-206.png?dl=0
here is my code in functions.php
add_filter( 'woocommerce_order_again_cart_item_data', 'trophy_order_again_cart_item_data', 10, 3 );
function trophy_order_again_cart_item_data($cart_item_meta, $product, $order)
{
$order_items = $order->get_items();
echo '<pre>';
print_r($order_items);
// print_r($product);
// print_r($order);
exit;
// remove_all_filters('woocommerce_add_to_cart_validation');
//Create an array of all the missing custom field keys that needs to be added in cart item.
// $customfields = [
// 'customfield_key1',
// 'customfield_key2',
// 'customfield_key3',
// 'customfield_key4',
// ];
// global $woocommerce;
// remove_all_filters( 'woocommerce_add_to_cart_validation' );
// if ( ! array_key_exists( 'item_meta', $cart_item_meta ) || ! is_array( $cart_item_meta['item_meta'] ) )
// foreach ( $customfields as $key ){
// if(!empty($product[$key])){
// $cart_item_meta[$key] = $product[$key];
// }
// }
return $cart_item_meta;
}
Let me know if any other way I can insert personalize options into the new Order for “Order Again”, It will be a great help if you can assist me achieve this goal as my whole project is under pause mode and it create problem for me with the client.
Let me know if you want to have a buyer account I will mail you those details.