Skip to content

Commit

Permalink
gw-fuzzy-comparison.php: Added snippet for fuzzy comparison.
Browse files Browse the repository at this point in the history
  • Loading branch information
saifsultanc committed Aug 28, 2024
1 parent 54aa65e commit a4f25cb
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?php
/**
* Gravity Perks // GP Conditional Pricing // Fuzzy Comparison for operator "is"
* http://gravitywiz.com/documentation/gravity-forms-conditional-pricing/
*
* This snippet adds fuzzy comparison for "is" operator with the GPCP rules.
* Gravity Wiz // Gravity Forms // Fuzzy Comparison for operator "is"
*
* This snippet adds fuzzy comparison for "is" operator with the GF conditional logic rules.
*/
class GPCP_Fuzzy_Match {
class GW_Fuzzy_Match {

private $_args;

Expand Down Expand Up @@ -63,7 +61,7 @@ public function output_script() {
<script type="text/javascript">
( function( $ ) {

window.GPCP_Fuzzy_Match = function( args ) {
window.GW_Fuzzy_Match = function( args ) {
var self = this;

// Copy all args to current object: (list expected props)
Expand Down Expand Up @@ -170,7 +168,7 @@ public function add_init_script( $form ) {
'threshold' => $this->_args['threshold'],
);

$script = 'new GPCP_Fuzzy_Match( ' . json_encode( $args ) . ' );';
$script = 'new GW_Fuzzy_Match( ' . json_encode( $args ) . ' );';
$slug = implode( '_', array( strtolower( __CLASS__ ), $this->_args['form_id'], $this->_args['field_id'] ) );

GFFormDisplay::add_init_script( $form['id'], $slug, GFFormDisplay::ON_PAGE_RENDER, $script );
Expand All @@ -183,8 +181,8 @@ public function is_applicable_form( $form ) {
}

# Configuration
new GPCP_Fuzzy_Match( array(
'form_id' => 1, // Replace with your form ID
'field_id' => 2, // Replace with your field ID
'threshold' => 1, // Define your threshold
new GW_Fuzzy_Match( array(
'form_id' => 1, // Replace with your form ID.
'field_id' => 2, // Replace with your field ID for which conditional logic needs to be fuzzy.
'threshold' => 1, // Define your threshold - It is the maximum number of allowed differences between two strings for them to be considered similar.
) );

0 comments on commit a4f25cb

Please sign in to comment.