Title: Javascript Error &#8211; here&#039;s the patch, please fix
Last modified: August 31, 2016

---

# Javascript Error – here's the patch, please fix

 *  Resolved [straightvisions GmbH](https://wordpress.org/support/users/matthias-reuter/)
 * (@matthias-reuter)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/javascript-error-heres-the-patch-please-fix/)
 * 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/](https://wordpress.org/plugins/woocommerce-pay-for-payment/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [fox-didl](https://wordpress.org/support/users/fox-didl/)
 * (@fox-didl)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/javascript-error-heres-the-patch-please-fix/#post-6977929)
 * Can you please fix this in the following version? We are happy to find this solution,
   because we had this issue also. But this is just a hot-fix for the actual version.
 *  [no.dots](https://wordpress.org/support/users/nodots-1/)
 * (@nodots-1)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/javascript-error-heres-the-patch-please-fix/#post-6977966)
 * [@matthias-reuter](https://wordpress.org/support/users/matthias-reuter/), thank
   you so much for this hot-fix! We’re in need for this.
 * @pay4pay, could you please fix this in the following update?
 *  [Michael Rimbach](https://wordpress.org/support/users/rimbimbi/)
 * (@rimbimbi)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/javascript-error-heres-the-patch-please-fix/#post-8328508)
 * [@podpirate](https://wordpress.org/support/users/podpirate/) Issue still exists.
   Could you please fix it? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Javascript Error – here's the patch, please fix’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-pay-for-payment/assets/icon-256x256.png?rev=
   2541841)
 * [Pay for Payment for WooCommerce](https://wordpress.org/plugins/woocommerce-pay-for-payment/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-pay-for-payment/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-pay-for-payment/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-pay-for-payment/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-pay-for-payment/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-pay-for-payment/reviews/)

 * 3 replies
 * 4 participants
 * Last reply from: [Michael Rimbach](https://wordpress.org/support/users/rimbimbi/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/javascript-error-heres-the-patch-please-fix/#post-8328508)
 * Status: resolved