Add user meta upon checkout
-
Hi,
I am setting up a webshop using Woocommerce. It is a bespoke suit shop. Users can select fabrics etc. In the order process users can give their measurements. I am storing all size data in session array variable. The sizes output correctly in the cart (just tested using echo in cart.php) and also on checkout page (top of page class-wc-checkout.php).
But when I want to add the sizes to the user meta, using add_user_meta , the meta_key is stored in the database, but the meta_value is empty.
I use this code around line 252 in class-wc-checkout.php:
if ( $this->customer_id )
do_action( ‘woocommerce_checkout_update_user_meta’, $this->customer_id, $this->posted );$size1=$_SESSION[‘sizes’][0];
add_user_meta( $this->customer_id, ‘_size1’, $size1);Is my session data somehow destroyed when the “place order” button is clicked?
In the above example I only store the first item of the array in the database. I would like to store the array itself.
Can anyone please help me with getting my sizes array in the wp_usermeta table?
Thanks in advance!!
- The topic ‘Add user meta upon checkout’ is closed to new replies.