Skip to content

Commit e04e400

Browse files
authored
Create gpqr-auto-submit-on-scan-with-gppa.js
1 parent f503440 commit e04e400

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Gravity Perks // GP QR Code // Automatically Submit After Successful Scan (w/ Populate Anything)
3+
* https://gravitywiz.com/documentation/gravity-forms-qr-code/
4+
*
5+
* You want to auto-submit the form after you've scanned a QR code but you're using Populate Anything
6+
* to populate other fields based on the value scanned. You need to wait for Populate Anything to
7+
* finish fetching and populating that data before the form can be submitted. This snippet handles
8+
* that logic for you.
9+
*
10+
* We recommend installing this snippet with our free Custom Javascript plugin:
11+
* https://gravitywiz.com/gravity-forms-custom-javascript/
12+
*/
13+
gform.addAction( 'gpqr_on_scan_success', function( decodedText, decodedResult, gpqrObj ) {
14+
$( document ).off( 'gppa_updated_batch_fields.gpqr' );
15+
$( document ).on( 'gppa_updated_batch_fields.gpqr', function( event, formId ) {
16+
if ( gpqrObj.formId == formId ) {
17+
setTimeout( function() {
18+
$( '#gform_{0}'.format( formId ) ).submit();
19+
} );
20+
}
21+
} );
22+
} );

0 commit comments

Comments
 (0)