New Zenner
- Join Date:
- May 2006
- Posts:
- 13
- Plugin Contributions:
- 0
[Done 1.3.8] Apostrophes in any order data w/ authorize.net database logging on
I have experienced other errors related to this bug (http://www.zen-cart.com/forum/showthread.php?p=404423) while using 1.3.7 (and just finished upgrading to 1.3.8a which doesn't appear to fix it). Some of the discussion has centered around what is sent to authorize.net, but the other issue is invalid database update statements due to unmatched apostrophes.
If any field in the order data contains an apostrophe -- whether in product names, customer name, customer address, etc -- and if "Enable Database Storage" is set to TRUE in the AIM module configuration, then the customer will receive a hard SQL error message when attempting to complete their order.
This is the fix that has worked for me (recently updated for 1.3.8a):
In authorizenet_aim.php, replace line 619:
$sql = $db->bindVars($sql, ':sentData', print_r($this->reportable_submit_data, true), 'string');
with:
$reportable_submit_data_text = print_r($this->reportable_submit_data, true);
$reportable_submit_data_text = str_replace("'", "''", $reportable_submit_data_text);
$sql = $db->bindVars($sql, ':sentData', $reportable_submit_data_text, 'string');
This effectively replaces single ' characters in the string to be saved with '' which works correctly. However, I am new to PHP, so there is probably a more elegant way to handle this.
Bjornar