<?php

/**
 * Modify the value of a price field between pages in a multi-page Gravity Forms form.
 *
 * @param array $form The Gravity Forms form array.
 * @return array The modified form array.
 */
add_action('gform_pre_render', 'cwpai_modify_price_field');
add_action('gform_pre_validation', 'cwpai_modify_price_field');

function cwpai_modify_price_field($form) {
    // Define the form ID and price field ID
    $target_form_id = 1; // Replace with your form ID
    $price_field_id = 2; // Replace with your price field ID

    // Check if the current form is the target form
    if ($form['id'] != $target_form_id) {
        return $form;
    }

    // Get the current page of the form
    $current_page = GFFormDisplay::get_current_page($form['id']);

    // Check if the current page is the desired page for modification (e.g., page 2)
    if ($current_page == 2) {
        // Loop through the form fields
        foreach ($form['fields'] as &$field) {
            // Check if the field is a product field and matches the price field ID
            if ($field->type == 'product' && $field->id == $price_field_id) {
                // Modify the base price of the field
                $field->basePrice = 1234; // Set your desired price value here
                break;
            }
        }
    }

    return $form;
}