• Resolved straightvisions GmbH

    (@matthias-reuter)


    This plugin generates a javascript error on checkout page:

    “Uncaught ReferenceError: $fragment_refresh is not defined”

    This should be solved by loading that javascript from an external file instead of inline embedding.

    Additionally, the javascript-code has an error trying to load a var “$fragment_refresh” which should be “fragment_refresh”.

    Hotfix (will be update compatible until issue has been fixed by plugin author):

    Insert into functions.php:

    // WooCommerce Pay for Payment Fix by Matthias Reuter
    remove_action('woocommerce_review_order_after_submit' , array(Pay4Pay::instance(),'print_autoload_js'));
    add_action('wp_enqueue_scripts', 'pay4pay_scripts' );
    function pay4pay_scripts(){
    	wp_enqueue_script('pay4pay', get_stylesheet_directory_uri().'/pay4pay.js', array('wc-cart-fragments'), false, true);
    }

    Create new file pay4pay.js within theme’s directory with following content:

    jQuery(document).ready(function($){
    	$(document.body).on('change', 'input[name="payment_method"]', function() {
    		if ( typeof pagetype !== 'undefined'){
    			$('body').trigger('update_checkout');
    			$.ajax( fragment_refresh );
    		}
    	});
    });

    https://wordpress.org/plugins/woocommerce-pay-for-payment/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Javascript Error – here's the patch, please fix’ is closed to new replies.