Home › Forums › WooCommerce Personalized Product Options Manager (PPOM) › Re Order with previous order Personalized selected options and values
- This topic has 8 replies, 3 voices, and was last updated 6 years ago by
Jane Brian.
-
AuthorPosts
-
November 8, 2017 at 7:24 am #8048
Digitize Info System
ParticipantHi Najeeb,
Is there a way that I can re-order with Previous order Personalize selected options and their values.
I have added this hook.
/** * Add an "order again" button in Recent Orders list * added to completed order list. */ add_filter( 'woocommerce_my_account_my_orders_actions', 'wrob_add_order_again_aciton', 10, 2 ); function wrob_add_order_again_aciton( $actions, $order ) { if ( ! $order || ! $order->has_status( 'completed' ) || ! is_user_logged_in() ) { return; } $actions['order-again'] = array( 'url' => wp_nonce_url( add_query_arg( 'order_again', $order->id ) , 'woocommerce-order_again' ), 'name' => __( 'Order Again', 'Avada' ) ); return $actions; }
But it only adds the items without previously selected Personalize Options and values.
It will be a great help as I am finding a hard time to understand the table structure and finding the hooks in the code to achieve this.
Thanks
November 8, 2017 at 2:35 pm #8050nmedia
KeymasterHi,
thanks for your sharing but how can re-order work, mean user have to set option against meta fields.
November 9, 2017 at 5:33 am #8052Digitize Info System
ParticipantBy Re order I mean to say for example.
if I ordered a Trophy with Personalized engraving options and now when I do “Re Order” or “Order Again” the previous options for Personalize it not being reflected in. and I want to figure this out.
November 9, 2017 at 6:40 pm #8053Digitize Info System
ParticipantHello Najeeb,
Any help related to this is much appriciated, thanks.
November 13, 2017 at 12:21 pm #8055Digitize Info System
ParticipantHi Najeeb,
I am yet on this to find a clue, I find when doing “Order Again” the personalize options from previous order’s variation_id is coming “0” thus Woocommerce treat this as “Out of Stock”
can you help me around fixing this issue on how to bring the Personalize option from previous order and set for a new order, if it is a mysql Query then I am also going to implement this.
Your help is much appreciated, thanks.
November 13, 2017 at 3:05 pm #8056nmedia
KeymasterHi,
Well I have to see what action are perform while ‘Order Again’, as all meta fields are rendered on product page and when we click add to cart data is trasnferred from _POST object to cart object.
November 14, 2017 at 4:45 am #8059Digitize Info System
ParticipantHi 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.
November 14, 2017 at 7:09 am #8060Digitize Info System
ParticipantHello Najeeb,
I found there is one hook in plugin.class.php
add_filter ( 'woocommerce_add_cart_item_data', array ($this, 'add_product_meta_to_cart' ), 10, 2 );
/* * Adding product meta to cart A very important function */ function add_product_meta_to_cart($the_cart_data, $product_id) {
I am also trying to do same like this for “Order Again”
add_filter ( 'woocommerce_order_again_cart_item_data', array ($this, 'add_product_meta_to_cart' ), 10, 2 );
But still I am not able to Add “Personalize Meta” to new order.
let me know if I am doing this right?
-
This reply was modified 7 years, 5 months ago by
Digitize Info System. Reason: code was not perfectly encoded
April 18, 2019 at 2:08 pm #11484Jane Brian
KeymasterHI
It has been a long while for this topic, so we are closing this. -
This reply was modified 7 years, 5 months ago by
-
AuthorPosts
- The topic ‘Re Order with previous order Personalized selected options and values’ is closed to new replies.