← All changes
|
stripe/controllers/FrmTransLiteActionsController.php
+35
-0
6.29
→
trunk
View file →
| @@ -410,8 +410,9 @@ | ||
| 410 | 410 | $settings_for_action = array( |
| 411 | 411 | 'id' => $payment_action->ID, |
| 412 | 412 | 'first_name' => $payment_action->post_content['billing_first_name'], |
| 413 | 413 | 'last_name' => $payment_action->post_content['billing_last_name'], |
| 414 | + 'address' => $payment_action->post_content['billing_address'] ?? '', | |
| 414 | 415 | 'gateways' => $payment_action->post_content['gateway'], |
| 415 | 416 | 'fields' => self::get_fields_for_price( $payment_action ), |
| 416 | 417 | 'one' => $payment_action->post_content['type'], |
| 417 | 418 | 'email' => $payment_action->post_content['email'], |
| @@ -472,8 +473,14 @@ | ||
| 472 | 473 | if ( $field->type !== 'gateway' ) { |
| 473 | 474 | return $values; |
| 474 | 475 | } |
| 475 | 476 | |
| 477 | + if ( FrmAppHelper::is_form_builder_page() ) { | |
| 478 | + // The hooks this uses can get called in the form builder and settings pages. | |
| 479 | + // But we do not need the script in this case. | |
| 480 | + return $values; | |
| 481 | + } | |
| 482 | + | |
| 476 | 483 | // This is also called from the frm_enqueue_form_scripts hook. |
| 477 | 484 | // With this here, the value of frm_stripe_vars.settings[0].fields is -1 |
| 478 | 485 | // This is because the amount value is processed and a shortcode is not found in '000'. |
| 479 | 486 | FrmStrpLiteActionsController::load_scripts( (int) $field->form_id ); |
| @@ -588,8 +595,14 @@ | ||
| 588 | 595 | $settings['credit_card'] = $credit_card_field_id; |
| 589 | 596 | } |
| 590 | 597 | } |
| 591 | 598 | |
| 599 | + if ( ! in_array( 'stripe', $settings['gateway'], true ) ) { | |
| 600 | + // We only need a gateway field for Stripe add-on compatibility, | |
| 601 | + // so unless Stripe is selected, we can return early. | |
| 602 | + return $settings; | |
| 603 | + } | |
| 604 | + | |
| 592 | 605 | $gateway_field_id = FrmDb::get_var( |
| 593 | 606 | 'frm_fields', |
| 594 | 607 | array( |
| 595 | 608 | 'type' => 'gateway', |
| @@ -660,6 +673,28 @@ | ||
| 660 | 673 | |
| 661 | 674 | $submit_order = (int) $submit_field->field_order; |
| 662 | 675 | FrmField::update( $submit_field->id, array( 'field_order' => $submit_order + 1 ) ); |
| 663 | 676 | return $submit_order; |
| 677 | + } | |
| 678 | + | |
| 679 | + /** | |
| 680 | + * Remove credit card validation errors. | |
| 681 | + * | |
| 682 | + * @param array $errors | |
| 683 | + * @param stdClass $field | |
| 684 | + * | |
| 685 | + * @return array | |
| 686 | + */ | |
| 687 | + public static function remove_cc_errors( $errors, $field ) { | |
| 688 | + $field_id = $field->temp_id ?? $field->id; | |
| 689 | + | |
| 690 | + if ( isset( $errors[ 'field' . $field_id . '-cc' ] ) ) { | |
| 691 | + unset( $errors[ 'field' . $field_id . '-cc' ] ); | |
| 692 | + } | |
| 693 | + | |
| 694 | + if ( isset( $errors[ 'field' . $field_id ] ) ) { | |
| 695 | + unset( $errors[ 'field' . $field_id ] ); | |
| 696 | + } | |
| 697 | + | |
| 698 | + return $errors; | |
| 664 | 699 | } |
| 665 | 700 | } |