File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed
Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 1212
1313use GFCommon ;
1414use Pronamic \WordPress \Number \Number ;
15+ use Pronamic \WordPress \Number \Parser as NumberParser ;
1516use Pronamic \WordPress \Money \Currency ;
1617use Pronamic \WordPress \Money \Money ;
1718use Pronamic \WordPress \Pay \AbstractGatewayIntegration ;
@@ -356,9 +357,24 @@ public function entry_post_save( $lead, $form ) {
356357 $ line ->set_unit_price ( new Money ( $ value , $ currency ) );
357358
358359 if ( array_key_exists ( 'quantity ' , $ product ) ) {
359- $ quantity = Number::from_mixed ( $ product ['quantity ' ] );
360-
361- $ value = $ value ->multiply ( $ quantity );
360+ try {
361+ $ parser = new NumberParser ();
362+
363+ $ quantity = $ parser ->parse ( $ product ['quantity ' ] );
364+
365+ $ value = $ value ->multiply ( $ quantity );
366+ } catch ( \Exception $ exception ) {
367+ $ exception = new \Exception (
368+ \sprintf (
369+ 'Couldn’t parse Gravity Forms product field `%s` quantity to a number. ' ,
370+ \esc_html ( $ key )
371+ ),
372+ 0 ,
373+ $ exception
374+ );
375+
376+ throw $ exception ;
377+ }
362378 }
363379
364380 $ line ->set_total_amount ( new Money ( $ value , $ currency ) );
You can’t perform that action at this time.
0 commit comments