Re: Known Bugs (and fixes) with v1.3.8
Problem: Lookup of fields in products or products_description by products_id in the Admin
Solution: change the function file:
/admin/includes/functions/general.php
from approximately lines 3120 to 3138 where it reads:
Code:
////
// return any field from products or products_description table
// Example: zen_products_lookup('3', 'products_date_added');
// function zen_products_lookup($product_id, $what_field = 'products_name', $language = $_SESSION['languages_id']) {
function zen_products_lookup($product_id, $what_field = 'products_name', $language = '') {
global $db;
if (empty($language)) $language = $_SESSION['languages_id'];
$product_lookup = $db->Execute("select " . $what_field . " as lookup_field
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id ='" . $product_id . "'
and pd.language_id = '" . $language . "'");
$return_field = $product_lookup->fields['lookup_field'];
return $return_field;
}
To read:
Code:
////
// return any field from products or products_description table
// Example: zen_products_lookup('3', 'products_date_added');
// function zen_products_lookup($product_id, $what_field = 'products_name', $language = $_SESSION['languages_id']) {
function zen_products_lookup($product_id, $what_field = 'products_name', $language = '') {
global $db;
if (empty($language)) $language = $_SESSION['languages_id'];
$product_lookup = $db->Execute("select " . $what_field . " as lookup_field
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id ='" . $product_id . "'
and pd.products_id = p.products_id
and pd.language_id = '" . $language . "'");
$return_field = $product_lookup->fields['lookup_field'];
return $return_field;
}
Thanks for catching the forgotten update, torvista ...
PayPal IPN transactions not storing properly
Symptom: PayPal Website Payments Standard transcations not completing properly and the following PHP error occurs while processing the IPN notification:
Quote:
PHP Fatal error: Call to a member function add() on a non-object in /includes/functions/functions_email.php on line 287
Workaround: To attempt to stop the "fatal" error when the email error occurs, try the following:
Edit /includes/auto_loaders/paypal_ipn.core.php
and add this to the end of the file (and remove the ?> on the last line if it exists in the file):
Code:
/**
* Breakpoint 130.
*
* messageStack = new messageStack();
*
*/
$autoLoadConfig[130][] = array('autoType'=>'classInstantiate',
'className'=>'messageStack',
'objectName'=>'messageStack');
problem in ot_gv shows MySQL error when redeeming invalid GV code
Problem: Attempting to redeem a gift certificate using an invalid code can cause a MySQL error to appear.
Solution: Make the following code change:
Edit /includes/modules/order_total/ot_gv.php
Around line 219 you'll see this section of code:
Code:
// check for validity
$gv_result = $db->Execute("select coupon_id, coupon_type, coupon_amount from " . TABLE_COUPONS . " where coupon_code = '" . zen_db_prepare_input($_POST['gv_redeem_code']) . "'");
Add the new line as shown:
Code:
// check for validity
$_POST['gv_redeem_code'] = preg_replace('/[^0-9a-zA-Z]/', '', $_POST['gv_redeem_code']);
$gv_result = $db->Execute("select coupon_id, coupon_type, coupon_amount from " . TABLE_COUPONS . " where coupon_code = '" . zen_db_prepare_input($_POST['gv_redeem_code']) . "'");
Re: Known Bugs (and fixes) with v1.3.8
Problem:
"1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-0, 0' at line 11"
This can also result in PCI scans failing.
Discussed in more detail here: http://www.zen-cart.com/forum/showthread.php?t=108941
Cause:
If you set any of the Admin->Configuration->Maximum Values to zero, the above situation may occur.
Fix:
There are a few ways to avert this situation:
a) Don't set Maximum Value settings to 0.
b) Change /includes/classes/split_page_results.php to detect 0 values and assign something different if that happens:
At line 25 find this section, and insert the new line as highlighted:
Code:
/* class constructor */
function splitPageResults($query, $max_rows, $count_key = '*', $page_holder = 'page', $debug = false) {
global $db;
$max_rows = ($max_rows == '' || $max_rows == 0) ? 20 : $max_rows;
$this->sql_query = $query;
$this->page_name = $page_holder;
c) Change /includes/classes/split_page_results.php to handle the "-0" situation more gracefully if it ever occurs:
At line 84, find this:
Code:
// fix offset error on some versions
if ($offset < 0) { $offset = 0; }
$this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;
}
and change it to this:
Code:
// fix offset error on some versions
if ($offset <= 0) { $offset = 0; }
$this->sql_query .= " limit " . ($offset > 0 ? $offset . ", " : '') . $this->number_of_rows_per_page;
}
I recommend implementing all three :blush:
Shipping module not honoring tax_basis setting
Problem: Shipping module tax calculations not honoring the tax_basis flag setting.
Solution: Small code change posted here: http://www.zen-cart.com/forum/showthread.php?t=133906
10413 errors with PayPal Express Checkout
There are some cases when a 10413 error will occur with a PayPal Express Checkout transaction. It seems to be associated mostly with stores who use the tax-included pricing option.
A workaround which has produced moderate success is this:
edit /includes/modules/payment/paypalwpp.php
around line 535 you'll see:
Code:
$response = $doPayPal->DoExpressCheckoutPayment($_SESSION['paypal_ec_token'],
$_SESSION['paypal_ec_payer_id'],
number_format((isset($options['AMT']) ? $options['AMT'] : $order_amount), 2),
$options);
Change that by adding/editing as follows:
Code:
if (!isset($options['AMT'])) $options['AMT'] = number_format($order_amount, 2, '.', '');
$response = $doPayPal->DoExpressCheckoutPayment($_SESSION['paypal_ec_token'],
$_SESSION['paypal_ec_payer_id'],
$options['AMT'],
$options);
Additionally, MAKE SURE you have the ot_subtotal module enabled in Admin->Modules->Order Total.
Fix inspired by a thought by lsenft
Re: Known Bugs (and fixes) with v1.3.8 / v1.3.8a
Problem: Discount Coupon Category Restrictions are not always working right ...
Solution: change a function in:
/includes/functions/functions_general.php
around lines 856 - 879 with:
Code:
function validate_for_category($product_id, $coupon_id) {
global $db;
$retVal = 'none';
$productCatPath = zen_get_product_path($product_id);
$catPathArray = array_reverse(explode('_', $productCatPath));
$sql = "SELECT count(*) AS total
FROM " . TABLE_COUPON_RESTRICT . "
WHERE category_id = -1
AND coupon_restrict = 'Y'
AND coupon_id = " . (int)$coupon_id . " LIMIT 1";
$checkQuery = $db->execute($sql);
foreach ($catPathArray as $catPath) {
$sql = "SELECT * FROM " . TABLE_COUPON_RESTRICT . "
WHERE category_id = " . (int)$catPath . "
AND coupon_id = " . (int)$coupon_id;
$result = $db->execute($sql);
if ($result->recordCount() > 0 && $result->fields['coupon_restrict'] == 'N') return true;
if ($result->recordCount() > 0 && $result->fields['coupon_restrict'] == 'Y') return false;
}
if ($checkQuery->fields['total'] > 0) {
return false;
} else {
return 'none';
}
}
Setting payment modules to "enabled=false" instead of Removing sometimes causes probs
Symptom: An order is received, but is marked as being paid-for via a module whose "Enabled" status was set to "False".
Solutions: There are two recommended steps:
1. If you are NOT using a given module on your site, then click Remove.
Leaving it active with only setting its "enabled" status to "false" causes the system to have to process that module's code even though it's false. The only reason to leave it installed but left as enabled=false is if you have added custom code to the module to have it self-enable only during certain circumstances. Otherwise the module should be Remove by clicking the Remove button.
2. Make the following code edit to help the system handle exceptions more consistently:
/includes/classes/payment.php
Change line 74:
Code:
$GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];
By replacing that one line with these several lines:
Code:
$paymentClass = new $include_modules[$i]['class'];
if ($paymentClass->enabled)
{
$GLOBALS[$include_modules[$i]['class']] = $paymentClass;
}
JPY currency problem in PayPal Express Checkout
Problem: Submitting PayPal Express Checkout transactions in JPY currency may have problems if currency exchange happens based on exchange rates for JPY that are not whole numbers.
Solution: Minor code change as posted here: http://www.zen-cart.com/forum/showpo...4&postcount=14
Re: Known Bugs (and fixes) with v1.3.8 / v1.3.8a
Problem: Issues where adding Product with Attributes adds to the quantity of the same Product with a different Attribute combination ...
Solution: Update the function zen_get_uprid in the file:
/includes/functions/functions_general.php
and change the function:
Code:
////
// Return a product ID with attributes
function zen_get_uprid($prid, $params) {
//print_r($params);
$uprid = $prid;
if ( (is_array($params)) && (!strstr($prid, ':')) ) {
while (list($option, $value) = each($params)) {
if (is_array($value)) {
while (list($opt, $val) = each($value)) {
$uprid = $uprid . '{' . $option . '}' . trim($opt);
}
break;
}
//CLR 030714 Add processing around $value. This is needed for text attributes.
$uprid = $uprid . '{' . $option . '}' . trim($value);
}
//CLR 030228 Add else stmt to process product ids passed in by other routines.
$md_uprid = '';
$md_uprid = md5($uprid);
return $prid . ':' . $md_uprid;
} else {
return $prid;
}
}
to read:
Code:
////
// Return a product ID with attributes
function zen_get_uprid($prid, $params) {
//print_r($params);
$uprid = $prid;
if ( (is_array($params)) && (!strstr($prid, ':')) ) {
while (list($option, $value) = each($params)) {
if (is_array($value)) {
while (list($opt, $val) = each($value)) {
$uprid = $uprid . '{' . $option . '}' . trim($opt);
}
} else {
//CLR 030714 Add processing around $value. This is needed for text attributes.
$uprid = $uprid . '{' . $option . '}' . trim($value);
}
} //CLR 030228 Add else stmt to process product ids passed in by other routines.
$md_uprid = '';
$md_uprid = md5($uprid);
return $prid . ':' . $md_uprid;
} else {
return $prid;
}
}
thanks to more-solutions for bringing this to our attention with a solution to correct the problem ...