gpfup-count-files.js

Code

Filename: gpfup-count-files.js

/**
* Experimental Snippet 🧪
*/
jQuery(function() {
  // Update "123" to your form ID and "4" to your File Upload field ID.
	if (typeof window['GPFUP_123_4'] === 'undefined') {
		return;
	}
	
  // Update "123" to your form ID and "4" to your File Upload field ID.
	var store = window.GPFUP_123_4.$store;
	
	store.subscribe(function(mutation, state) {
		if (mutation.type !== 'SET_FILES') {
			return;
		}
		// Update "5" to your Single Product field ID - or - update `#input_123_5_1` to your desired input's HTML ID.
		jQuery( '#input_123_5_1' ).val( state.files.length ).change();
	});
});

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.