Skip to content

Commit

Permalink
gpecf-set-discount-amount-by-field-value.php: Fixed an issue with t…
Browse files Browse the repository at this point in the history
…he snippet not dynamically updating the discount value.
  • Loading branch information
saifsultanc committed Jul 18, 2023
1 parent 13e0900 commit 87c34c1
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public function output_script() {
value = value.split( '|' )[0];
}
self.$getInput( self.discountFieldId ).data( 'amount', value );
var amount = parseFloat(value, 10);
if ( !isNaN( amount ) ) {
var formattedAmount = amount.toLocaleString( 'en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 2, maximumFractionDigits: 2 } );
$( '.ginput_discount_' + self.formId + '_' + self.discountFieldId ).html( formattedAmount );
}
}

self.$getInput = function( fieldId ) {
Expand Down

0 comments on commit 87c34c1

Please sign in to comment.