How to add a value to $form_state in Drupal 7

I have an old legacy site that I need to add a value to $form_state for in Drupal 7. Unfortunately, I’m having a tough time finding any resources for Drupal 7 as its a bit out of date. I’ve tried the following: $form_state[‘values’][‘field_transaction_id’][‘und’][0][‘value’] = $result->transaction->id; $form_state[‘input’][‘field_transaction_id’][‘und’][0][‘value’] = $result->transaction->id; $form_state[‘build_info’][‘args’][0]->field_transaction_id[‘und’][0][‘value’] = $result->transaction->id; I’m sure there’s a…

how change add to cart button text and show text with added quantity of product on shop page without page load

function change_button_text( $product_id, $button_text ) { foreach( WC()->cart->get_cart() as $item ) { if( $product_id === $item[‘product_id’] ) { $itemq = $item[‘quantity’]; return __(‘Add ( ‘.$itemq.’ )’ , ‘woocommerce’); } } return $button_text; } add_filter( ‘woocommerce_product_add_to_cart_text’, ‘change_ajax_add_to_cart_button_text’, 10, 2 ); function change_ajax_add_to_cart_button_text( $button_text, $product ) { if ( $product->is_type(‘simple’) || $product->is_type(‘subscription’) ) { $button_text = change_button_text(…