: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// For entries, only return true if the payment field has an amount.
! empty( $field['amount'] ) &&
! empty( wpforms_sanitize_amount( $field['amount'] ) )
* Check to see if a form has an active payment gateway configured.
* @param array $form_data Form data and settings.
function wpforms_has_payment_gateway( $form_data ) {
// PayPal Standard check.
if ( ! empty( $form_data['payments']['paypal_standard']['enable'] ) ) {
if ( ! empty( $form_data['payments']['stripe']['enable'] ) ) {
* Allow modifying whether a form has an active payment gateway.
* @param bool $result True if a form has an active payment gateway.
* @param array $form_data Form data and settings.
return (bool) apply_filters( 'wpforms_has_payment_gateway', false, $form_data );
* Get payment total amount from entry.
* @since 1.8.2.2 Added PHP max() function before returning a total.
* @param array $fields List of fields.
function wpforms_get_total_payment( $fields ) {
$fields = wpforms_get_payment_items( $fields );
if ( empty( $fields ) ) {
foreach ( $fields as $field ) {
if ( ! empty( $field['amount'] ) ) {
$amount = wpforms_sanitize_amount( $field['amount'] );
if ( ! empty( $field['quantity'] ) ) {
$amount *= (int) $field['quantity'];
$total = max( 0, $total );
return wpforms_sanitize_amount( $total );
* Get payment fields in an entry.
* @param array $fields List of fields.
* @return array|bool False if no fields provided, otherwise array.
function wpforms_get_payment_items( $fields = [] ) {
if ( empty( $fields ) ) {
$payment_fields = wpforms_payment_fields();
foreach ( $fields as $id => $field ) {
empty( $field['type'] ) ||
empty( $field['amount'] ) ||
! in_array( $field['type'], $payment_fields, true ) ||
empty( wpforms_sanitize_amount( $field['amount'] ) ) ||
( isset( $field['quantity'] ) && ! $field['quantity'] )
// Remove all non-payment fields as well as payment fields with no amount or empty quantity.
* Determine if field has quantity enabled.
* @param array $field Field data.
* @param array $form_data Form data.
function wpforms_payment_has_quantity( array $field, array $form_data ): bool {
if ( ! isset( $field['id'] ) ) {
if ( isset( $field['quantity'] ) ) {
$field_settings = $form_data['fields'][ $field['id'] ] ?? [];
if ( empty( $field_settings['enable_quantity'] ) ) {
// Quantity is available only for `single` format of the Single payment field.
if ( $field_settings['type'] === 'payment-single' && $field_settings['format'] !== 'single' ) {
// Otherwise return true.
// It covers the Dropdown Items field (and others where the quantity will be supported).
* Formatted payment field value with quantity.
* @param array $field Field data.
function wpforms_payment_format_quantity( array $field ): string {
if ( empty( $field['value'] ) ) {
return sprintf( /* translators: %1$s - payment amount; %2$d - payment quantity. */
esc_html__( '%1$s × %2$d', 'wpforms-lite' ),