get_field( $amount_variable, false ); if ( $form_field ) { $form_field = $form_field->to_formatted_array(); $fields_collection = forminator_fields_to_array(); if ( isset( $form_field['type'] ) ) { if ( 'calculation' === $form_field['type'] ) { // Calculation field get the amount from pseudo_submit_data if ( isset( $pseudo_submitted_data[ $amount_variable ] ) ) { $payment_amount = $pseudo_submitted_data[ $amount_variable ]; } } elseif ( 'currency' === $form_field['type'] ) { // Currency field get the amount from submitted_data $field_id = $form_field['element_id']; if ( isset( $submitted_data[ $field_id ] ) ) { $payment_amount = $submitted_data[ $field_id ]; } } else { if ( isset( $fields_collection[ $form_field['type'] ] ) ) { /** @var Forminator_Field $field_object */ $field_object = $fields_collection[ $form_field['type'] ]; $field_id = $form_field['element_id']; $submitted_field_data = isset( $submitted_data[ $field_id ] ) ? $submitted_data[ $field_id ] : null; $payment_amount = $field_object->get_calculable_value( $submitted_field_data, $form_field ); } } } } } } if( $payment_amount ){ $payment_amount = str_replace(',', '', $payment_amount ); } return $payment_amount; }, 999, 5 ); add_filter( 'http_response', function( $response, $params, $url ){ if( strpos( $url, 'paypal.com/v2/checkout/orders/') && 200 === wp_remote_retrieve_response_code( $response ) ){ $body = json_decode( wp_remote_retrieve_body( $response ) ); if( isset( $body->purchase_units[0]->amount->value ) && $body->purchase_units[0]->amount->value > 999 ){ $forminator_paypal_field_path = WP_PLUGIN_DIR .'/forminator/library/fields/paypal.php'; if( @file_exists( $forminator_paypal_field_path ) ){ $paypal_field_content = @file_get_contents( $forminator_paypal_field_path ); if( strpos( $paypal_field_content, 'number_format( $charge_amount, 2 )') ){ $body->purchase_units[0]->amount->value = number_format( $body->purchase_units[0]->amount->value, 2 ); $response['body'] = json_encode( $body ); } } } } return $response; }, 10, 3 ); } }