Need help with JS code

HTML with JS code is added to mutual payment getaway description in Payments are not fully working. The added tabs are not clickable.

  • Ash

    Hello Mwale

    That field doesn't allow js code, that's why JS code is not working for that field.

    As a workaround, please add a macro code in manual payment gateway field, like: %%%MY_JS_CODE%%%

    You need to place the above code exactly where you have used the js code.

    Now use the following code:

    add_filter( 'ms_gateway_manual_purchase_info_content', function( $info ) {
    	$html = '<script type="text/javascript">
    	jQuery(function($){
    		alert(123);
    	});
    	</script>';
    
    	return str_replace( '%%%MY_JS_CODE%%%', $html, $info );
    } );

    Here, in $html variable put your js code.

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.