Skip to content

Instantly share code, notes, and snippets.

@spivurno
Created March 8, 2020 00:40
Show Gist options
  • Select an option

  • Save spivurno/bf3b4a944b307d8ec57e29f77cd0ac91 to your computer and use it in GitHub Desktop.

Select an option

Save spivurno/bf3b4a944b307d8ec57e29f77cd0ac91 to your computer and use it in GitHub Desktop.
/**
* Gravity Perks // Pay Per Word // Surprise, Pay Per Character!
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/
*/
gform.addFilter( 'gpppw_word_count', function( wordCount, text, gwppw, ppwField, formId ) {
// Pay per character instead of words.
var words = text.split( '' );
return words == null ? 0 : words.length;
} );
<?php
/**
* Gravity Perks // Pay Per Word // Surprise, Pay Per Character!
* https://gravitywiz.com/documentation/gravity-forms-pay-per-word/
*/
add_filter( 'gpppw_word_count', function( $word_count, $words ) {
$words = str_split( trim( $words ) );
return count( $words );
}, 10, 2 );
@mohitit

mohitit commented Mar 8, 2020

Copy link
Copy Markdown

hello David,
Thanks! for the help...One minor issue ...One the Gravity form the prices are coming fine...But in the notification email the price is still coming according to pay per word..

@mohitit

mohitit commented Mar 8, 2020

Copy link
Copy Markdown

i have written the gp-pay-per-word-i-mean-character.php code in my function.php file

@spivurno

spivurno commented Mar 8, 2020

Copy link
Copy Markdown
Author

@mohitit Drop us a line via support: http://gravitywiz.com/support/ We'll be happy to dig in. πŸ™‚

@mohitit

mohitit commented Mar 9, 2020

Copy link
Copy Markdown

@spivurno

Copy link
Copy Markdown
Author

@mohitit I posted the link to our support in my last. πŸ™‚

@kingofching

Copy link
Copy Markdown

Where does the js go? I use snippets for the php part.

@mohitit

mohitit commented Jul 28, 2020

Copy link
Copy Markdown

You can HTML Block in form and add js block there

@kingofching

Copy link
Copy Markdown

Thank you!

@spivurno

spivurno commented Nov 10, 2021 •

Copy link
Copy Markdown
Author

@JanStorm

Copy link
Copy Markdown

FYI: This snipped does not work with every character. See my pull request here: gravitywiz/snippet-library#403

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment