: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @param array $fields Order summary footer.
* @param int $total Fields total.
$foot = (array) apply_filters( 'wpforms_forms_fields_payment_total_field_builder_order_summary_preview_foot', [], $total );
* Allow to filter builder order summary fields total.
* @param string $total Fields total.
$total = apply_filters( 'wpforms_forms_fields_payment_total_field_builder_order_summary_preview_total', $total );
$total = wpforms_format_amount( $total, true );
'label' => __( 'Total', 'wpforms-lite' ),
'class' => 'wpforms-order-summary-preview-total',
$total_width = strlen( html_entity_decode( $total, ENT_COMPAT, 'UTF-8' ) ) + 4;
* Allow to filter builder order summary total column width.
* @param int $total_width Total column width.
$total_width = (int) apply_filters( 'wpforms_forms_fields_payment_total_field_builder_order_summary_preview_total_width', $total_width );
return [ $items, $foot, $total_width ];
* Prepare payment fields data for summary preview.
* @param array $form_data Form data.
private function prepare_payment_fields_data( array $form_data ): array {
$payment_fields = wpforms_payment_fields();
foreach ( $form_data['fields'] as $field ) {
( ! isset( $field['price'] ) && empty( $field['choices'] ) ) ||
! in_array( $field['type'], $payment_fields, true )
$this->prepare_payment_field_choices( $field, $fields, $total );
$this->prepare_payment_field_single( $field, $fields, $total );
* Allow to filter items in the order summary footer.
* @param array $fields Fields.
$foot = (array) apply_filters( 'wpforms_forms_fields_payment_total_field_order_summary_preview_foot', $foot );
$total = wpforms_format_amount( $total, true );
'label' => __( 'Total', 'wpforms-lite' ),
'class' => 'wpforms-order-summary-preview-total',
return [ $fields, $foot, strlen( html_entity_decode( $total, ENT_COMPAT, 'UTF-8' ) ) + 3 ];
* Prepare payment single data for summary preview.
* @param array $field Field data.
* @param array $fields Fields data.
* @param float $total Fields total.
private function prepare_payment_field_single( array $field, array &$fields, float &$total ) {
if ( ! empty( $field['choices'] ) ) {
$quantity = $this->get_payment_field_min_quantity( $field );
$field_amount = ! empty( $field['price'] ) ? wpforms_sanitize_amount( $field['price'] ) * $quantity : 0;
'label' => $field['label'],
'quantity' => $this->get_payment_field_min_quantity( $field ),
'amount' => wpforms_format_amount( $field_amount, true ),
'is_hidden' => ! $quantity,
'class' => 'wpforms-order-summary-field',
* Prepare payment field choices data for summary preview.
* @param array $field Field data.
* @param array $fields Fields data.
* @param float $total Fields total.
private function prepare_payment_field_choices( array $field, array &$fields, float &$total ) {
if ( empty( $field['choices'] ) ) {
$quantity = $this->get_payment_field_min_quantity( $field );
$default_choice_key = $this->get_classic_dropdown_default_choice_key( $field );
foreach ( $field['choices'] as $key => $choice ) {
$choice_amount = ! empty( $choice['value'] ) ? wpforms_sanitize_amount( $choice['value'] ) * $quantity : 0;
$is_default = ! empty( $choice['default'] ) || ( isset( $default_choice_key ) && (int) $key === $default_choice_key );
'label' => $field['label'] . ' - ' . $choice['label'],
'amount' => wpforms_format_amount( $choice_amount, true ),
'is_hidden' => ! $is_default || ! $quantity,
'class' => 'wpforms-order-summary-field',
$total += $choice_amount;
* Get classic dropdown default choice key.
* @param array $field Field Settings.
private function get_classic_dropdown_default_choice_key( array $field ) {
if ( $field['type'] !== 'payment-select' || $field['style'] !== 'classic' || ! empty( $field['placeholder'] ) ) {
foreach ( $field['choices'] as $key => $choice ) {
if ( ! isset( $choice['default'] ) ) {
return array_key_first( $field['choices'] );
* Get payment field minimum quantity.
* @param array $field Field data.
private function get_payment_field_min_quantity( array $field ): int {
if ( ! wpforms_payment_has_quantity( $field, $this->form_data ) || ! isset( $field['min_quantity'] ) ) {
return (int) $field['min_quantity'];
* Add class to the builder field preview.
* @param string $css Class names.
* @param array $field Field properties.
public function preview_field_class( $css, $field ) {
if ( $field['type'] !== $this->type ) {
if ( $this->is_summary_enabled( $field ) ) {
$css .= ' wpforms-summary-enabled';
* Add order summary to the confirmation settings.
* @param WPForms_Builder_Panel_Settings $settings Settings.
* @param int $field_id Field ID.
public function add_confirmation_setting( $settings, int $field_id ) {
esc_html__( 'Show order summary after confirmation message', 'wpforms-lite' ),
'input_id' => 'wpforms-panel-field-confirmations-message_order_summary-' . $field_id,
'input_class' => 'wpforms-panel-field-confirmations-message_order_summary',
'subsection' => $field_id,
* Show order summary on the confirmation page.
* @param array $confirmation Current confirmation data.
* @param array $form_data Form data and settings.
* @param array $fields Sanitized field data.
* @param int $entry_id Entry id.
public function order_summary_confirmation( array $confirmation, array $form_data, array $fields, int $entry_id ) {
if ( empty( $confirmation['message_order_summary'] ) ) {
foreach ( $fields as $field ) {
if ( $field['type'] !== $this->type ) {
// Check if total field exists on the form.
echo '<div class="wpforms-confirmation-container-order-summary">';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo wpforms_process_smart_tags( '{order_summary}', $form_data, $fields, $entry_id );