Home / Admin / Hiding the Currency Symbol in WPForms Total Field
Duplicate Snippet

Embed Snippet on Your Site

Hiding the Currency Symbol in WPForms Total Field

This code snippet removes the following currency symbols from the Total field: £, $, €.

20+
Code Preview
php
<?php
/**
 * Hide currency symbol in WPForms.
 */
add_filter( 'wpforms_currencies', function( $currencies ) {
	$form_data = wpforms()->obj( 'process' )->form_data ?? [];
	if ( empty( $form_data ) ) {
		$frontend = wpforms()->obj( 'frontend' );
		if ( ! empty( $frontend->forms ) ) {
			// Get the first form being rendered as a fallback.
			$form_data = reset( $frontend->forms );
		}
	}
	if ( ! empty( $form_data ) && wpforms_has_field_type( 'payment-total', $form_data ) ) {
		foreach ( $currencies as $code => $data ) {
			$currencies[ $code ]['symbol'] = '';
		}
	}
	return $currencies;
} );

Comments

Add a Comment