Saving data to WooCommerce session Saving data to WooCommerce session wordpress wordpress

Saving data to WooCommerce session


It's more saying Thank you for solving my problem. But here is an answer, too:

The post meta could not been updated because there is no $order_id parameter in your callback function. This should do the trick:

function retrieve_and_save_group_input_value_to_order_meta( $order_id ) {    $retrived_group_input_value = WC()->session->get( 'group_order_data' );    update_post_meta( $order_id, '_create_new_group', $retrived_group_input_value );}add_action('woocommerce_checkout_update_order_meta', 'retrieve_and_save_group_input_value_to_order_meta');


Here is another approach.

1st page:

 session_start();//place this at the top of all code $data = $_POST['create_new_group']; $_SESSION['custom_create_new_group']=$data;

Now in another page write the following to receive the value:

session_start(); //optional     $retrive_price =  $_SESSION['custom_create_new_group'];