Ticket #1268 (new defect)

Opened 17 months ago

Custom Fields not Submitting

Reported by: ParanoidSardine Owned by: mufasa
Priority: high Component: wp-e-commerce
Severity: normal Keywords: custom checkout fields
Cc:

Description

In checkout.class.php there is a bug that prevents all custom fields being submitted when a customer checkouts. In WPEC 3.7.8 on line 911 inside of the "save_forms_to_db" function the "get_count_checkout_fields" function is called. This function presumably determines the number of checkout custom fields to expect. When examining the "get_count_checkout_fields" function, I noticed that the SQL limits the query to only non-heading custom fields. Line 946 reads:

$sql = "SELECT COUNT(*) FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `type` !='heading' AND `active`='1'";

I understand why the heading custom fields would be withheld in this query; however, this later becomes a problem as the number gleaned from this query presents a mismatch with the number of fields that are available in the $_POSTcollected_data? array. What happens is that the foreach loop that begins at 913 breaks before all of the checkout custom fields have been considered. In certain cases, this leads to the custom fields not being submitted to the database, thereby causing a number of subtle errors throughout the system and lost information.

The fix then is to match up the number of expected custom fields with the number of submitted custom fields. I was able to accomplish this by modifying the line shown above. As such, I would like to propose changing line 946 to :

$sql = "SELECT COUNT(*) FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active`='1'";

On the one site in which this became an issue, I was able to fix the problem with this fix.

I also checked to see if this bug had been caught and fixed in the 3.8 beta and it has not been changed. In the 3.8 betas, the line number for the fix is 811.

Please note that this is my first time contributing to WPEC trac, so apologies if I'm breaking any conventions. I'd appreciate help with etiquette if necessary.

Attachments

checkout.class.patch Download (470 bytes) - added by ParanoidSardine 17 months ago.
Patch for suggested changes

Change History

Changed 17 months ago by ParanoidSardine

Patch for suggested changes

Note: See TracTickets for help on using tickets.