A Customer creates a subscription and tells me what he requires via WooCommerce. The requirements are stored inside of the user profile using the user meta data. When he updates this in the WooCommerce my account area on the front end, it updates it fine within the Wordpress customer profile. No problems there.
The problem i have is, When he updates the requirements via a custom field inside of the WooCommerce account area on the front end, the subscription keeps renewing his old requirements over and over. How do i get it to so that when the subscription renews it uses the latest custom field data found inside the account area?
Example: https://i.stack.imgur.com/UEMpY.png
This is what i have at the moment. In this example below, I tried to copy the user meta to the order meta and update it when the subscription renews. For some reason it's not updating. Perhaps this is the wrong way all together. My PHP is very limited. Can anyone advise?
// update subscription meta order
add_action('woocommerce_subscription_renewal_payment_complete','subscription_renew');
function subscription_renew( $order_id ) {
$order = wc_get_order( $order_id ); // get the order id
$user_id = $order->get_user_id(); // get the user id
if ( $order->get_total() > 1 ) { // not sure why this is here
$getsend = get_user_meta( $user_id, 'send' ); // grab the user meta field 'send'
$getcategories = get_user_meta( $user_id, 'categories' ); // grab the user meta field 'categories'
// now do the update
$order->update_meta_data( $user_id, 'send', $getsend ); // update user order meta field 'send'
$order->update_meta_data( $user_id, 'categories', $getcategories ); // update user order meta field 'categories'
$order_id = $order->save(); // save the order
return $order_id;
}
}