Home / Admin / WP Simple Pay: Add Yes and No Values to Checkbox
Duplicate Snippet

Embed Snippet on Your Site

WP Simple Pay: Add Yes and No Values to Checkbox

If the value is `on` or `off,` change it to `yes` or `no`. Otherwise, return the standard value.

Code Preview
php
<?php
add_filter(
    'simpay_get_paymentintent_args_from_payment_form_request',
    function( $args ) {
        $args['metadata'] = array_map(
            function( $value ) {
                // If the value is `on` or `off`, change it. Otherwise return the normal value.
                if ( 'off' === $value ) {
				  return 'No';
				} else if ( 'on' === $value ) {
				  return 'Yes';
				}
				return $value;
            },
            $args['metadata']
        );
        return $args;
    }
);

Comments

Add a Comment