Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wpforms-.../src/Forms/Fields/PaymentT...
File: Field.php
*
[500] Fix | Delete
* @param array $fields Order summary footer.
[501] Fix | Delete
* @param int $total Fields total.
[502] Fix | Delete
*/
[503] Fix | Delete
$foot = (array) apply_filters( 'wpforms_forms_fields_payment_total_field_builder_order_summary_preview_foot', [], $total );
[504] Fix | Delete
[505] Fix | Delete
/**
[506] Fix | Delete
* Allow to filter builder order summary fields total.
[507] Fix | Delete
*
[508] Fix | Delete
* @since 1.8.7
[509] Fix | Delete
*
[510] Fix | Delete
* @param string $total Fields total.
[511] Fix | Delete
*/
[512] Fix | Delete
$total = apply_filters( 'wpforms_forms_fields_payment_total_field_builder_order_summary_preview_total', $total );
[513] Fix | Delete
[514] Fix | Delete
$total = wpforms_format_amount( $total, true );
[515] Fix | Delete
[516] Fix | Delete
$foot[] = [
[517] Fix | Delete
'label' => __( 'Total', 'wpforms-lite' ),
[518] Fix | Delete
'quantity' => '',
[519] Fix | Delete
'amount' => $total,
[520] Fix | Delete
'class' => 'wpforms-order-summary-preview-total',
[521] Fix | Delete
];
[522] Fix | Delete
[523] Fix | Delete
$total_width = strlen( html_entity_decode( $total, ENT_COMPAT, 'UTF-8' ) ) + 4;
[524] Fix | Delete
[525] Fix | Delete
/**
[526] Fix | Delete
* Allow to filter builder order summary total column width.
[527] Fix | Delete
*
[528] Fix | Delete
* @since 1.8.7
[529] Fix | Delete
*
[530] Fix | Delete
* @param int $total_width Total column width.
[531] Fix | Delete
*/
[532] Fix | Delete
$total_width = (int) apply_filters( 'wpforms_forms_fields_payment_total_field_builder_order_summary_preview_total_width', $total_width );
[533] Fix | Delete
[534] Fix | Delete
return [ $items, $foot, $total_width ];
[535] Fix | Delete
}
[536] Fix | Delete
[537] Fix | Delete
/**
[538] Fix | Delete
* Prepare payment fields data for summary preview.
[539] Fix | Delete
*
[540] Fix | Delete
* @since 1.8.7
[541] Fix | Delete
*
[542] Fix | Delete
* @param array $form_data Form data.
[543] Fix | Delete
*
[544] Fix | Delete
* @return array
[545] Fix | Delete
*/
[546] Fix | Delete
private function prepare_payment_fields_data( array $form_data ): array {
[547] Fix | Delete
[548] Fix | Delete
$payment_fields = wpforms_payment_fields();
[549] Fix | Delete
$fields = [];
[550] Fix | Delete
$foot = [];
[551] Fix | Delete
$total = 0;
[552] Fix | Delete
[553] Fix | Delete
foreach ( $form_data['fields'] as $field ) {
[554] Fix | Delete
[555] Fix | Delete
if (
[556] Fix | Delete
( ! isset( $field['price'] ) && empty( $field['choices'] ) ) ||
[557] Fix | Delete
! in_array( $field['type'], $payment_fields, true )
[558] Fix | Delete
) {
[559] Fix | Delete
continue;
[560] Fix | Delete
}
[561] Fix | Delete
[562] Fix | Delete
$this->prepare_payment_field_choices( $field, $fields, $total );
[563] Fix | Delete
$this->prepare_payment_field_single( $field, $fields, $total );
[564] Fix | Delete
}
[565] Fix | Delete
[566] Fix | Delete
/**
[567] Fix | Delete
* Allow to filter items in the order summary footer.
[568] Fix | Delete
*
[569] Fix | Delete
* @since 1.8.7
[570] Fix | Delete
*
[571] Fix | Delete
* @param array $fields Fields.
[572] Fix | Delete
*/
[573] Fix | Delete
$foot = (array) apply_filters( 'wpforms_forms_fields_payment_total_field_order_summary_preview_foot', $foot );
[574] Fix | Delete
[575] Fix | Delete
$total = wpforms_format_amount( $total, true );
[576] Fix | Delete
[577] Fix | Delete
$foot[] = [
[578] Fix | Delete
'label' => __( 'Total', 'wpforms-lite' ),
[579] Fix | Delete
'quantity' => '',
[580] Fix | Delete
'amount' => $total,
[581] Fix | Delete
'class' => 'wpforms-order-summary-preview-total',
[582] Fix | Delete
];
[583] Fix | Delete
[584] Fix | Delete
return [ $fields, $foot, strlen( html_entity_decode( $total, ENT_COMPAT, 'UTF-8' ) ) + 3 ];
[585] Fix | Delete
}
[586] Fix | Delete
[587] Fix | Delete
/**
[588] Fix | Delete
* Prepare payment single data for summary preview.
[589] Fix | Delete
*
[590] Fix | Delete
* @since 1.8.7
[591] Fix | Delete
*
[592] Fix | Delete
* @param array $field Field data.
[593] Fix | Delete
* @param array $fields Fields data.
[594] Fix | Delete
* @param float $total Fields total.
[595] Fix | Delete
*/
[596] Fix | Delete
private function prepare_payment_field_single( array $field, array &$fields, float &$total ) {
[597] Fix | Delete
[598] Fix | Delete
if ( ! empty( $field['choices'] ) ) {
[599] Fix | Delete
return;
[600] Fix | Delete
}
[601] Fix | Delete
[602] Fix | Delete
$quantity = $this->get_payment_field_min_quantity( $field );
[603] Fix | Delete
$field_amount = ! empty( $field['price'] ) ? wpforms_sanitize_amount( $field['price'] ) * $quantity : 0;
[604] Fix | Delete
[605] Fix | Delete
$fields[] = [
[606] Fix | Delete
'label' => $field['label'],
[607] Fix | Delete
'quantity' => $this->get_payment_field_min_quantity( $field ),
[608] Fix | Delete
'amount' => wpforms_format_amount( $field_amount, true ),
[609] Fix | Delete
'is_hidden' => ! $quantity,
[610] Fix | Delete
'class' => 'wpforms-order-summary-field',
[611] Fix | Delete
'data' => [
[612] Fix | Delete
'field' => $field['id'],
[613] Fix | Delete
],
[614] Fix | Delete
];
[615] Fix | Delete
[616] Fix | Delete
$total += $field_amount;
[617] Fix | Delete
}
[618] Fix | Delete
[619] Fix | Delete
/**
[620] Fix | Delete
* Prepare payment field choices data for summary preview.
[621] Fix | Delete
*
[622] Fix | Delete
* @since 1.8.7
[623] Fix | Delete
*
[624] Fix | Delete
* @param array $field Field data.
[625] Fix | Delete
* @param array $fields Fields data.
[626] Fix | Delete
* @param float $total Fields total.
[627] Fix | Delete
*/
[628] Fix | Delete
private function prepare_payment_field_choices( array $field, array &$fields, float &$total ) {
[629] Fix | Delete
[630] Fix | Delete
if ( empty( $field['choices'] ) ) {
[631] Fix | Delete
return;
[632] Fix | Delete
}
[633] Fix | Delete
[634] Fix | Delete
$quantity = $this->get_payment_field_min_quantity( $field );
[635] Fix | Delete
$default_choice_key = $this->get_classic_dropdown_default_choice_key( $field );
[636] Fix | Delete
[637] Fix | Delete
foreach ( $field['choices'] as $key => $choice ) {
[638] Fix | Delete
[639] Fix | Delete
$choice_amount = ! empty( $choice['value'] ) ? wpforms_sanitize_amount( $choice['value'] ) * $quantity : 0;
[640] Fix | Delete
$is_default = ! empty( $choice['default'] ) || ( isset( $default_choice_key ) && (int) $key === $default_choice_key );
[641] Fix | Delete
[642] Fix | Delete
$fields[] = [
[643] Fix | Delete
'label' => $field['label'] . ' - ' . $choice['label'],
[644] Fix | Delete
'quantity' => $quantity,
[645] Fix | Delete
'amount' => wpforms_format_amount( $choice_amount, true ),
[646] Fix | Delete
'is_hidden' => ! $is_default || ! $quantity,
[647] Fix | Delete
'class' => 'wpforms-order-summary-field',
[648] Fix | Delete
'data' => [
[649] Fix | Delete
'field' => $field['id'],
[650] Fix | Delete
'choice' => $key,
[651] Fix | Delete
],
[652] Fix | Delete
];
[653] Fix | Delete
[654] Fix | Delete
if ( $is_default ) {
[655] Fix | Delete
$total += $choice_amount;
[656] Fix | Delete
}
[657] Fix | Delete
}
[658] Fix | Delete
}
[659] Fix | Delete
[660] Fix | Delete
/**
[661] Fix | Delete
* Get classic dropdown default choice key.
[662] Fix | Delete
*
[663] Fix | Delete
* @since 1.8.7
[664] Fix | Delete
*
[665] Fix | Delete
* @param array $field Field Settings.
[666] Fix | Delete
*
[667] Fix | Delete
* @return int|null
[668] Fix | Delete
*/
[669] Fix | Delete
private function get_classic_dropdown_default_choice_key( array $field ) {
[670] Fix | Delete
[671] Fix | Delete
if ( $field['type'] !== 'payment-select' || $field['style'] !== 'classic' || ! empty( $field['placeholder'] ) ) {
[672] Fix | Delete
return null;
[673] Fix | Delete
}
[674] Fix | Delete
[675] Fix | Delete
foreach ( $field['choices'] as $key => $choice ) {
[676] Fix | Delete
if ( ! isset( $choice['default'] ) ) {
[677] Fix | Delete
continue;
[678] Fix | Delete
}
[679] Fix | Delete
[680] Fix | Delete
return (int) $key;
[681] Fix | Delete
}
[682] Fix | Delete
[683] Fix | Delete
return array_key_first( $field['choices'] );
[684] Fix | Delete
}
[685] Fix | Delete
[686] Fix | Delete
/**
[687] Fix | Delete
* Get payment field minimum quantity.
[688] Fix | Delete
*
[689] Fix | Delete
* @since 1.8.7
[690] Fix | Delete
*
[691] Fix | Delete
* @param array $field Field data.
[692] Fix | Delete
*
[693] Fix | Delete
* @return int
[694] Fix | Delete
*/
[695] Fix | Delete
private function get_payment_field_min_quantity( array $field ): int {
[696] Fix | Delete
[697] Fix | Delete
if ( ! wpforms_payment_has_quantity( $field, $this->form_data ) || ! isset( $field['min_quantity'] ) ) {
[698] Fix | Delete
return 1;
[699] Fix | Delete
}
[700] Fix | Delete
[701] Fix | Delete
return (int) $field['min_quantity'];
[702] Fix | Delete
}
[703] Fix | Delete
[704] Fix | Delete
/**
[705] Fix | Delete
* Add class to the builder field preview.
[706] Fix | Delete
*
[707] Fix | Delete
* @since 1.8.7
[708] Fix | Delete
*
[709] Fix | Delete
* @param string $css Class names.
[710] Fix | Delete
* @param array $field Field properties.
[711] Fix | Delete
*
[712] Fix | Delete
* @return string
[713] Fix | Delete
*/
[714] Fix | Delete
public function preview_field_class( $css, $field ) {
[715] Fix | Delete
[716] Fix | Delete
if ( $field['type'] !== $this->type ) {
[717] Fix | Delete
return $css;
[718] Fix | Delete
}
[719] Fix | Delete
[720] Fix | Delete
if ( $this->is_summary_enabled( $field ) ) {
[721] Fix | Delete
$css .= ' wpforms-summary-enabled';
[722] Fix | Delete
}
[723] Fix | Delete
[724] Fix | Delete
return $css;
[725] Fix | Delete
}
[726] Fix | Delete
[727] Fix | Delete
/**
[728] Fix | Delete
* Add order summary to the confirmation settings.
[729] Fix | Delete
*
[730] Fix | Delete
* @since 1.8.7
[731] Fix | Delete
*
[732] Fix | Delete
* @param WPForms_Builder_Panel_Settings $settings Settings.
[733] Fix | Delete
* @param int $field_id Field ID.
[734] Fix | Delete
*/
[735] Fix | Delete
public function add_confirmation_setting( $settings, int $field_id ) {
[736] Fix | Delete
[737] Fix | Delete
wpforms_panel_field(
[738] Fix | Delete
'toggle',
[739] Fix | Delete
'confirmations',
[740] Fix | Delete
'message_order_summary',
[741] Fix | Delete
$settings->form_data,
[742] Fix | Delete
esc_html__( 'Show order summary after confirmation message', 'wpforms-lite' ),
[743] Fix | Delete
[
[744] Fix | Delete
'input_id' => 'wpforms-panel-field-confirmations-message_order_summary-' . $field_id,
[745] Fix | Delete
'input_class' => 'wpforms-panel-field-confirmations-message_order_summary',
[746] Fix | Delete
'parent' => 'settings',
[747] Fix | Delete
'subsection' => $field_id,
[748] Fix | Delete
]
[749] Fix | Delete
);
[750] Fix | Delete
}
[751] Fix | Delete
[752] Fix | Delete
/**
[753] Fix | Delete
* Show order summary on the confirmation page.
[754] Fix | Delete
*
[755] Fix | Delete
* @since 1.8.7
[756] Fix | Delete
*
[757] Fix | Delete
* @param array $confirmation Current confirmation data.
[758] Fix | Delete
* @param array $form_data Form data and settings.
[759] Fix | Delete
* @param array $fields Sanitized field data.
[760] Fix | Delete
* @param int $entry_id Entry id.
[761] Fix | Delete
*/
[762] Fix | Delete
public function order_summary_confirmation( array $confirmation, array $form_data, array $fields, int $entry_id ) {
[763] Fix | Delete
[764] Fix | Delete
if ( empty( $confirmation['message_order_summary'] ) ) {
[765] Fix | Delete
return;
[766] Fix | Delete
}
[767] Fix | Delete
[768] Fix | Delete
$total_exists = false;
[769] Fix | Delete
[770] Fix | Delete
foreach ( $fields as $field ) {
[771] Fix | Delete
if ( $field['type'] !== $this->type ) {
[772] Fix | Delete
continue;
[773] Fix | Delete
}
[774] Fix | Delete
[775] Fix | Delete
$total_exists = true;
[776] Fix | Delete
[777] Fix | Delete
break;
[778] Fix | Delete
}
[779] Fix | Delete
[780] Fix | Delete
// Check if total field exists on the form.
[781] Fix | Delete
if ( ! $total_exists ) {
[782] Fix | Delete
return;
[783] Fix | Delete
}
[784] Fix | Delete
[785] Fix | Delete
echo '<div class="wpforms-confirmation-container-order-summary">';
[786] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[787] Fix | Delete
echo wpforms_process_smart_tags( '{order_summary}', $form_data, $fields, $entry_id );
[788] Fix | Delete
echo '</div>';
[789] Fix | Delete
}
[790] Fix | Delete
}
[791] Fix | Delete
[792] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function