bhays / gravity-forms-quantity-limits

Limit the display of product fields based on the number of entries.
2 stars 4 forks source link

Current Amount (SUM) is wrong #2

Closed gnistdesign closed 11 years ago

gnistdesign commented 11 years ago

Hi,

I'm using this plugin on a site with simple product fields. When I manually summarize the entries, the amount is 38. The plugin reports 99. When I echo the result from _get_field_valuessum() I notice the query looks for _fieldnumber 9 in _rg_leaddetail, but the correct field_number would be 9.3.

Any suggestions?

WordPress 3.6 GravityForms 1.7.8 Gravity Forms Quantiy Limits 0.6.4

Thanks!

bhays commented 11 years ago

Very strange. I just tested things with GF 1.7.8 and all quantities were computed okay. Is there a chance that other entries are in the trash but still marked active?

Could you send me an XML dump of your form for some more testing?

gnistdesign commented 11 years ago

No entries in the trash. I’ve used the «built-in» quantity in the product field, and not the stand-alone. Does that matter?

I’ll be happy to send you an XML dump, but I cannot find your contact info/e-mail address.

bhays commented 11 years ago

Correct, built-in quantity field is the only one that works. The stand alone quantity field won't be calculated right now.

Send the XML to benhays AT gmail and I'll have a look.

bhays commented 11 years ago

The SQL query sum(value) was counting all returned value fields. This includes the field name. In your case, your field name began with 5, so there was an extra 5 items returned with every sum().

I've modified the SQL query to only select and sum values that are integers to avoid this issue in the future.

You should see an update via WordPress shortly.