This thread is a collection of known bugs and their fixes ... specifically applicable to v1.3.8 / v1.3.8a.
FIRST, YOU SHOULD APPLY ALL KNOWN SECURITY PATCHES, as listed here:
http://www.zen-cart.com/forum/showthread.php?t=131115
Printable View
This thread is a collection of known bugs and their fixes ... specifically applicable to v1.3.8 / v1.3.8a.
FIRST, YOU SHOULD APPLY ALL KNOWN SECURITY PATCHES, as listed here:
http://www.zen-cart.com/forum/showthread.php?t=131115
Symptom:
Using v1.3.8 (not v1.3.8a). Getting: SMTP Error - Could Not Connect to SMTP Host
Solution:
Details and fix posted here:
http://www.zen-cart.com/forum/showthread.php?t=82570
NOTE: This issue is fixed in v1.3.8a ... announced here: http://www.zen-cart.com/forum/showth...780#post473780
Symptom:
Center boxes for NEW PRODUCTS and UPCOMING PRODUCTS show Products even when products_status = 0
Solution:
Fix SELECT statements in the two modules:
/includes/modules/new_products.php
This section around lines 40-45
Needs to be updated to:PHP Code:
$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_id in (" . $list_of_products . ")";
And then in the:PHP Code:
$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1
and p.products_id in (" . $list_of_products . ")";
/includes/modules/upcoming_products.php
around lines 43 to 50
to read:PHP Code:
$expected_query = "select p.products_id, pd.products_name, products_date_available as date_expected, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and p.products_id in (" . $list_of_products . ")
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
$display_limit .
$limit_clause;
PHP Code:
$expected_query = "select p.products_id, pd.products_name, products_date_available as date_expected, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and p.products_status = 1
and p.products_id in (" . $list_of_products . ")
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
$display_limit .
$limit_clause;
Symptom: Using PHP 4.3.2 (specifically), cannot stay logged in to the admin area
Cause: Inconsistency in how PHP 4.3.2 vs newer versions of PHP handle sessions.
Solution: See instructions in this post: http://www.zen-cart.com/forum/showpo...8&postcount=29
Symptom:
Tax calculation logic for Gift Vouchers.
Solution:
To fix for v1.3.8/1.3.8a you need to edit
includes/modules/order_total/ot_gv.php
at around line 294 you should see this code
you need to comment out that whole block so you getCode:
if ($this->include_tax) {
reset($order->info['tax_groups']);
foreach ($order->info['tax_groups'] as $key=>$value) {
$od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratio_tax;
$tax_deduct += $od_amount['tax_groups'][$key];
}
}
Code:// if ($this->include_tax) {
// reset($order->info['tax_groups']);
// foreach ($order->info['tax_groups'] as $key=>$value) {
// $od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratio_tax;
// $tax_deduct += $od_amount['tax_groups'][$key];
// }
// }
Symptom:
Admin Category/Product Listing is not showing prices when Customer Authorization is set to 1 or 2 ...
This was originally designed to make the Admin mirror the Catalog ... unfortunately, *somebody* ... er ... umm ... me ... forgot to finish this section of code so there was an additional switch in place of the customer_id session variable ... :blush:
This means, if you have your shop setup with Customer Authorization and you do not see the Prices in the Catalog ... Categories/Products ... it is because it is first checking if the prices "should" show ... this is not a valid test in the Admin and should be changed so that the Prices *always* show in the Admin ...
Temporary Solution:
This can be changed with a quick fix of:
/admin/includes/functions/functions_prices.php
NOTE: the STORE_STATUS is also there to do the same thing, that if you turn off the prices based on STORE_STATUS then the prices would turn off in the Admin as well ...PHP Code:
function zen_get_products_display_price($products_id) {
global $db, $currencies;
if (false) {
// 0 = normal shopping
// 1 = Login to shop
// 2 = Can browse but no prices
// verify display of prices
switch (true) {
case (CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == ''):
// customer must be logged in to browse
return '';
break;
case (CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == ''):
// customer may browse but no prices
return '';
break;
default:
// proceed normally
break;
}
}
// show case only
if (STORE_STATUS != '0') {
if (STORE_STATUS == '1') {
return '';
}
}
Both of these will be fixed in v1.4 with a better arrangement of code ...
Symptom: When doing checkout with Website Payments Pro and have only downloadable products in the cart (or otherwise don't require shipping for anything), error 10726 appears.
10726 - Invalid Data - There's an error with this transaction. Please enter a complete shipping address.
Cause: Partial shipping information is being sent, when none should be sent at all.
Solution: posted here: http://www.zen-cart.com/forum/showpo...82&postcount=4
This issue exists prior to v1.3.8, and is formally fixed in v1.4.0
Symptom: customer date of birth gets erased when editing customer records from the admin page, if the minimum length for the DOB field is set to zero
Solution: see this thread: http://www.zen-cart.com/forum/showthread.php?t=83839
Symptom: If you are using the low-order-fee module and using Linkpoint/Yourpay API payment module in v1.3.8, you will encounter some errors when submitting payments for processing.
Cause: the code wasn't written to support low-order-fee module
Solution: A newer version of this file has been posted here, to handle this bug and another related to coupons:
http://www.zen-cart.com/forum/showth...490#post563490
Symptom: On login page with something in your cart, you might see a "Division by zero" warning in module ot_group_pricing.php
Fix: Make the following edit:
/includes/modules/order_total/ot_group_pricing.php
around line 67 you'll see this section of code.
Add the line highlighted:Code:function calculate_deductions($order_total) {
global $db, $order;
$od_amount = array();
if ($order_total == 0) return $od_amount;
$orderTotal = $this->get_order_total();
Discussed here:
http://www.zen-cart.com/forum/showth...731#post487731
Symptom: In the admin area, when accessing pages that have pulldown menus on them, you might occasionally see a "catchable fatal error in html_output.php".
Happens only in PHP5
Cause: leftover legacy code incompatible with PHP5
Solution: Interim workaround is available by using the patched files posted here:
http://www.zen-cart.com/forum/showpo...0&postcount=10
Symptom:
There's a bug in v1.3.8 which only shows when you have
Admin->Configuration->Layout Settings->Categories - Always Show on Main Page = 1
Solution:
To fix it, edit your /includes/init_includes/init_add_crumbs.php file, by adding the indicated code, as shown in the highlighted area:http://www.zen-cart.com/forum/showthread.php?t=87093Code:if ($categories->RecordCount() > 0) {
$breadcrumb->add($categories->fields['categories_name'], zen_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
} elseif(SHOW_CATEGORIES_ALWAYS == 0) {
// if invalid, set the robots noindex/nofollow for this page
$robotsNoIndex = true;
break;
}
Symptom: "Invalid XML" errors when using the v1.3.8 LinkpointAPI payment module on orders which qualify for and select free-shipping.
Solution: http://www.zen-cart.com/forum/showth...397#post504397
Problem: When deleting "ALL attributes" for a given product via the Attributes Controller, AND the product has Download Files attached to it, an error appears, saying:Solution: The coding fix for this particular situation is posted here:Quote:
Fatal error: Cannot use object of type queryFactoryResult as array in /home/mysite/public_html/store/admin/includes/functions/general.php on line 2089
http://www.zen-cart.com/forum/showthread.php?t=88609
Minor issue:
Symptom: HTML-formatted emails generated by Tell-A-Friend always link to main default product-type. For example, if a product_music item was referenced, it would point to product_info instead of product_music_info in the URL.
Fix discussed here: http://www.zen-cart.com/forum/showthread.php?t=89606
Symptom: Categories Meta Tags cannot be removed once added
http://www.zen-cart.com/forum/showthread.php?t=86882
Solution: Replace the code for the categories meta tags:
/admin/categories.php
And change the code for the categories meta tags to read:
PHP Code:
// bof: categories meta tags
case 'update_category_meta_tags':
// add or update meta tags
//die('I SEE ' . $action . ' - ' . $_POST['categories_id']);
$categories_id = $_POST['categories_id'];
$languages = zen_get_languages();
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
$language_id = $languages[$i]['id'];
$check = $db->Execute("select *
from " . TABLE_METATAGS_CATEGORIES_DESCRIPTION . "
where categories_id = '" . (int)$categories_id . "'
and language_id = '" . (int)$language_id . "'");
if ($check->RecordCount() > 0) {
$action = 'update_category_meta_tags';
} else {
$action = 'insert_categories_meta_tags';
}
$sql_data_array = array('metatags_title' => zen_db_prepare_input($_POST['metatags_title'][$language_id]),
'metatags_keywords' => zen_db_prepare_input($_POST['metatags_keywords'][$language_id]),
'metatags_description' => zen_db_prepare_input($_POST['metatags_description'][$language_id]));
if ($action == 'insert_categories_meta_tags') {
$insert_sql_data = array('categories_id' => $categories_id,
'language_id' => $language_id);
$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
zen_db_perform(TABLE_METATAGS_CATEGORIES_DESCRIPTION, $sql_data_array);
} elseif ($action == 'update_category_meta_tags') {
if (empty($_POST['metatags_title'][$language_id]) && empty($_POST['metatags_keywords'][$language_id]) && empty($_POST['metatags_description'][$language_id])) {
$remove_categories_metatag = "DELETE from " . TABLE_METATAGS_CATEGORIES_DESCRIPTION . " WHERE categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$language_id . "'";
$db->Execute($remove_categories_metatag);
} else {
zen_db_perform(TABLE_METATAGS_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$language_id . "'");
}
}
}
zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
break;
// eof: categories meta tags
Symptom: Product Meta Tag leaving blank record
Solution: update the file:
/admin/includes/modules/update_products_meta_tags.php
New Code:
http://www.zen-cart.com/forum/showthread.php?t=86882PHP Code:
// check if new meta tags or existing
$check_meta_tags_description = $db->Execute("select products_id from " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " where products_id='" . $products_id . "'");
if ($check_meta_tags_description->RecordCount() <= 0) {
$action = 'new_product_meta_tags';
}
$languages = zen_get_languages();
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
$language_id = $languages[$i]['id'];
$sql_data_array = array('metatags_title' => zen_db_prepare_input($_POST['metatags_title'][$language_id]),
'metatags_keywords' => zen_db_prepare_input($_POST['metatags_keywords'][$language_id]),
'metatags_description' => zen_db_prepare_input($_POST['metatags_description'][$language_id]));
if ($action == 'new_product_meta_tags') {
$insert_sql_data = array('products_id' => $products_id,
'language_id' => $language_id);
$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
zen_db_perform(TABLE_META_TAGS_PRODUCTS_DESCRIPTION, $sql_data_array);
} elseif ($action == 'update_product_meta_tags') {
if (empty($_POST['metatags_title'][$language_id]) && empty($_POST['metatags_keywords'][$language_id]) && empty($_POST['metatags_description'][$language_id])) {
$remove_products_metatag = "DELETE from " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " WHERE products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'";
$db->Execute($remove_products_metatag);
} else {
zen_db_perform(TABLE_META_TAGS_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
}
}
}
zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '')));
}
Symptom:
Unknown column 'o.orders_id' in 'on clause' occurs in the Admin Orders screen when doing a search from the "Search by Product Name or ID:XX or Model" box (the standard "Search" box and Order ID searches work fine).
This happens on MySQL 5.0 and higher.
Solution:
In the /admin/orders.php, from lines 715 thru 750 there are three places where the following is found:change each of those to this instead:Code:from (" . TABLE_ORDERS . " o, " .
TABLE_ORDERS_STATUS . " s " .
Code:from (" . TABLE_ORDERS_STATUS . " s, " .
TABLE_ORDERS . " o " .
Posted and discussed here: http://www.zen-cart.com/forum/showth...384#post518384
Symptom: Using v1.3.8 and Linkpoint/yourpay API module along with a discount coupon would cause a SGS-002301 error to appear along with a message saying subtotals and chargetotal don't match.
Solution: Updated module file posted here: http://www.zen-cart.com/forum/showpo...nt=12&p=519955
NOTE: This fix also incorporates the ot_loworderfee fix posted earlier in this thread.
Problem: Back button not working in some instances and you go to the home page vs the last page
Solution: edit the file
/includes/functions/functions_general.php
around lines 989 - 1004 is the function:
replace it with the following:PHP Code:
////
// Set back button
function zen_back_link() {
if (sizeof($_SESSION['navigation']->path)-2 > 0) {
$back = sizeof($_SESSION['navigation']->path)-2;
$link = '<a href="' . zen_href_link($_SESSION['navigation']->path[$back]['page'], zen_array_to_string($_SESSION['navigation']->path[$back]['get'], array('action')), $_SESSION['navigation']->path[$back]['mode']) . '">';
} else {
if (isset($_SERVER['HTTP_REFERER']) && strstr(HTTP_SERVER, $_SERVER['HTTP_REFERER'])) {
$link= $_SERVER['HTTP_REFERER'];
} else {
$link = '<a href="' . zen_href_link(FILENAME_DEFAULT) . '">';
}
$_SESSION['navigation'] = new navigationHistory;
}
return $link;
}
Thanks to Absolute for posting this current solution ...PHP Code:
////
// Set back button
function zen_back_link() {
if (sizeof($_SESSION['navigation']->path)-2 > 0) {
$back = sizeof($_SESSION['navigation']->path)-2;
$link = '<a href="' . zen_href_link($_SESSION['navigation']->path[$back]['page'], zen_array_to_string($_SESSION['navigation']->path[$back]['get'], array('action')), $_SESSION['navigation']->path[$back]['mode']) . '">';
} else {
if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], HTTP_SERVER)) {
$link= '<a href="' . $_SERVER['HTTP_REFERER'].'">';
} else {
$link = '<a href="' . zen_href_link(FILENAME_DEFAULT) . '">';
}
$_SESSION['navigation'] = new navigationHistory;
}
return $link;
}
Note: it has been tested to some degree but not to 100% satisfaction ... granted I cannot break it thus far so perhaps it has ... :cool:
Problem: TEXT Attributes set to TEXTAREA with a limit on number of characters will delete the initially typed text when the maximum number of characters has been reached ...
Example: Maximum is set to 200 and the 201 character is typed and the first 200 characters get deleted when the warning is displayed ...
Solution:
Edit /includes/modules/pages/product_info/jscript_textarea_counter.js
change this:to this:Code:if (excesschars > 0) {
field.value = field.value.substring(0, excesschars);
alert("Error:\n\n- You are only allowed to enter up to"+maxchars+" characters.");
Do the same for other product types if needed ...Code:if (excesschars > 0) {
field.value = field.value.substring(0, maxchars);
alert("Error:\n\n- You are only allowed to enter up to"+maxchars+" characters.");
Several issues have been fixed in the LinkpointAPI payment module since v1.3.8 was first released. They are summarized here, with an updated module file:
The fixes included are:
- prevents submission of line-item details if partial quantities are entered (ie: any decimal places)
- prevents submission of line-item details if attribute content is longer than 128 characters - SGS-005000
- prevents submission of subtotal line-item details if discounts apply (Using v1.3.8 and Linkpoint/yourpay API module along with a discount coupon would cause a SGS-002301 error to appear along with a message saying subtotals and chargetotal don't match)
- commented code can be uncommented for other OT modules such as ot_loworderfee if needed
- traps for error condition if SGS-002301 subtotal mismatch occurs
- accommodates free-shipping cases correctly
- confirmed to not croak when handling ' marks in product names
Related forum posts:
http://www.zen-cart.com/forum/showthread.php?t=98895
http://www.zen-cart.com/forum/showthread.php?t=87388
http://www.zen-cart.com/forum/showthread.php?t=88813
http://www.zen-cart.com/forum/showthread.php?t=87901
http://www.zen-cart.com/forum/showthread.php?t=94387
NOTE: THESE FIXES ARE ALREADY BUILT-IN TO v1.3.9. YOU SHOULD BE UPGRADING, rather than just patching.
The following file, after unzipping, simply replaces your existing /includes/modules/payment/linkpoint_api.php file:
This bug isn't unique to v1.3.8 (has existed for many versions) but only shows in PHP5.
Symptom:
Fatal error: Cannot use object of type queryFactoryResult as array in /home/mydomain/public_html/admin/includes/graphs/banner_monthly.php on line 41
Solution:
Edit /admin/includes/graphs/banner_monthly.php ... line 41
Add the text as shown:
Code:$graph->SetTitle(sprintf(TEXT_BANNERS_MONTHLY_STATISTICS, $banner->fields['banners_title'], $year));
Problem: Minimum or Maximum or Units is not processing with attributes properly when added to cart ... also affects quantity discounts on mixed
Solution:
/includes/classes/shopping_cart.php
at lines 1401 and 1435 you have code that looks like this:add an extra line in both places, making it look like this:Code:// reset($this->contents); // breaks cart
$check_contents = $this->contents;
while (list($products_id, ) = each($check_contents)) {
Code:// reset($this->contents); // breaks cart
$check_contents = $this->contents;
reset($check_contents);
while (list($products_id, ) = each($check_contents)) {
ISSUE WITH GODADDY HOSTING CUSTOMERS VS PAYPAL
GoDaddy has made a change to their server configuration so that their proxy servers are no longer required.
The fix:
1. IF YOU ARE USING GODADDY HOSTING, go to Admin->Configuration->My Store->CURL Proxy Status, and turn it off.
That should be enough.
Alternate, "fix" which should *NOT* be needed:
2. THE FOLLOWING SHOULD NOT BE REQUIRED, but is left for reference:
This change in proxy configuration breaks the bandages originally added to the PayPal IPN handling to accommodate the need for the proxy ... and thus breaks the ability of the PayPal modules to receive updates from PayPal regarding transactions made in your stores.
This affects all the PayPal modules, and is unique to GoDaddy hosting accounts.
a) PayPal Website Payments Standard (IPN) transactions will not register in your store at all.
b) PayPal Website Payments Pro transactions will not see updates made such as refunds.
c) Express Checkout transactions will not show updates made such as refunds
The quick workaround to this is to make two small edits to one file:
/includes/modules/payment/paypal/paypal_functions.php
Around line 443 you'll see the following section of code.
Make the changes by adding the text shown in red:The proxy support will no longer be needed for future.Code:$proxy = $web;
if (false && CURL_PROXY_REQUIRED == 'True' && CURL_PROXY_SERVER_DETAILS != '') {
$proxy = parse_url($scheme . CURL_PROXY_SERVER_DETAILS);
$ssl = ($ssl == '') ? 'http://' : $ssl;
}
//Post Data
if (false && CURL_PROXY_REQUIRED == 'True' && CURL_PROXY_SERVER_DETAILS != '') {
$header = "POST " . $ssl . $web[host] . $web[path] . " HTTP/1.1\r\n";
$header .= "Host: $proxy[host]\r\n";
} else {
$header = "POST $web[path] HTTP/1.1\r\n";
$header .= "Host: $web[host]\r\n";
}
Problem: Multiple Languages showing in What's New sidebox
Solution: edit the file:
/includes/modules/sideboxes/whats_new.php
Change the select statement to read:
Code:$random_whats_new_sidebox_product_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name,
p.master_categories_id
from (" . TABLE_PRODUCTS . " p
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1 " . $display_limit;
Problem: In Admin customers display the right panel displays a $0.00 Gift Certificate balance when no order exists yet for a customer.
Solution: Add a function and change the display for the right panel
Add this function to the:
/admin/includes/functions/general.php
Then edit the file:PHP Code:
function zen_user_has_gv_balance($c_id) {
global $db;
$gv_result = $db->Execute("select amount from " . TABLE_COUPON_GV_CUSTOMER . " where customer_id = '" . (int)$c_id . "'");
if ($gv_result->RecordCount() > 0) {
if ($gv_result->fields['amount'] > 0) {
return $gv_result->fields['amount'];
}
}
return 0;
}
/admin/customers.php
And change:
to read:PHP Code:
$contents[] = array('text' => '<br />' . TEXT_INFO_GV_AMOUNT . ' ' . $currencies->format($customers_orders->fields['amount']));
PHP Code:
$customer_gv_balance = zen_user_has_gv_balance($cInfo->customers_id);
$contents[] = array('text' => '<br />' . TEXT_INFO_GV_AMOUNT . ' ' . $currencies->format($customer_gv_balance));
Problem: Sales made with Salemaker having trouble on some sales with Linked Products ...
Solution: update the code on the following files ...
Change the file:
/includes/functions/functions_lookups.php
Find the code:
and change to read:Code:/*
* Return a product's category
* TABLES: products_to_categories
*/
function zen_get_products_category_id($products_id) {
global $db;
$the_products_category_query = "select products_id, categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "'" . " order by products_id,categories_id";
$the_products_category = $db->Execute($the_products_category_query);
return $the_products_category->fields['categories_id'];
}
Then, in the Admin find the code in:Code:/*
* Return a product's category
* TABLES: products_to_categories
*/
function zen_get_products_category_id($products_id) {
global $db;
$the_products_category_query = "select products_id, master_categories_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'";
$the_products_category = $db->Execute($the_products_category_query);
return $the_products_category->fields['master_categories_id'];
}
/admin/includes/functions/general.php
that reads:
and change to read:Code:////
// Return a product's category
// TABLES: products_to_categories
function zen_get_products_category_id($products_id) {
global $db;
$the_products_category_query = "select products_id, categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $products_id . "'" . " order by products_id,categories_id";
$the_products_category = $db->Execute($the_products_category_query);
return $the_products_category->fields['categories_id'];
}
Code:////
// Return a product's category
// TABLES: products_to_categories
function zen_get_products_category_id($products_id) {
global $db;
$the_products_category_query = "select products_id, master_categories_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'";
$the_products_category = $db->Execute($the_products_category_query);
return $the_products_category->fields['master_categories_id'];
}
Problem: Group Discount being applied to shipping for VAT purposes
Resolution: http://www.zen-cart.com/forum/showth...972#post687972
Problem: Looking up fields in products and products_description and looking up fields in categories and categories_description ...
There are two function in the functions_lookups that will pull any field that you need from the products or products_description tables by just passing it the products_id ... and for pulling any field from the categories and categories_description tables just by passing the categories_id ...
However there is an error in both of them that needs a minor fix ...
The original code for product lookup:
/includes/functions/functions_lookups.php
The original code for category lookup :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 = '') {
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 ='" . (int)$product_id . "'
and pd.language_id = '" . (int)$language . "'");
$return_field = $product_lookup->fields['lookup_field'];
return $return_field;
}
However, there is a little bug in these that you will want to update:Quote:
/*
* Return any field from categories or categories_description table
* Example: zen_categories_lookup('10', 'parent_id');
*/
function zen_categories_lookup($categories_id, $what_field = 'categories_name', $language = '') {
global $db;
if (empty($language)) $language = $_SESSION['languages_id'];
$category_lookup = $db->Execute("select " . $what_field . " as lookup_field
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id ='" . (int)$categories_id . "'
and cd.language_id = '" . (int)$language . "'");
$return_field = $category_lookup->fields['lookup_field'];
return $return_field;
}
The new code for products look up:
The new code for categories look up: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 = '') {
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 ='" . (int)$product_id . "'
and pd.products_id = p.products_id
and pd.language_id = '" . (int)$language . "'");
$return_field = $product_lookup->fields['lookup_field'];
return $return_field;
}
Code:/*
* Return any field from categories or categories_description table
* Example: zen_categories_lookup('10', 'parent_id');
*/
function zen_categories_lookup($categories_id, $what_field = 'categories_name', $language = '') {
global $db;
if (empty($language)) $language = $_SESSION['languages_id'];
$category_lookup = $db->Execute("select " . $what_field . " as lookup_field
from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
where c.categories_id ='" . (int)$categories_id . "'
and c.categories_id = cd.categories_id
and cd.language_id = '" . (int)$language . "'");
$return_field = $category_lookup->fields['lookup_field'];
return $return_field;
}
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:
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.language_id = '" . $language . "'");
$return_field = $product_lookup->fields['lookup_field'];
return $return_field;
}
Thanks for catching the forgotten update, torvista ...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;
}
Symptom: PayPal Website Payments Standard transcations not completing properly and the following PHP error occurs while processing the IPN notification:Workaround: To attempt to stop the "fatal" error when the email error occurs, try the following:Quote:
PHP Fatal error: Call to a member function add() on a non-object in /includes/functions/functions_email.php on line 287
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: 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:Add the new line as shown: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']) . "'");
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']) . "'");
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:c) Change /includes/classes/split_page_results.php to handle the "-0" situation more gracefully if it ever occurs: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;
At line 84, find this:and change it to this:Code:// fix offset error on some versions
if ($offset < 0) { $offset = 0; }
$this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;
}
I recommend implementing all three :blush: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;
}
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
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:Change that by adding/editing as follows:Code:$response = $doPayPal->DoExpressCheckoutPayment($_SESSION['paypal_ec_token'],
$_SESSION['paypal_ec_payer_id'],
number_format((isset($options['AMT']) ? $options['AMT'] : $order_amount), 2),
$options);
Additionally, MAKE SURE you have the ot_subtotal module enabled in Admin->Modules->Order Total.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);
Fix inspired by a thought by lsenft
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';
}
}
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:By replacing that one line with these several lines:Code:$GLOBALS[$include_modules[$i]['class']] = new $include_modules[$i]['class'];
Code:$paymentClass = new $include_modules[$i]['class'];
if ($paymentClass->enabled)
{
$GLOBALS[$include_modules[$i]['class']] = $paymentClass;
}
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
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:
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);
}
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;
}
}
thanks to more-solutions for bringing this to our attention with a solution to correct the problem ...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;
}
}
Problem: Options Values with single and multiple quotes sometimes get truncated or cutoff
Solution:
Edit the file:
/admin/options_values_manager.php
change the line around 727:
to read:Code:$inputs .= $languages[$i]['code'] . ': <input type="text" name="value_name[' . $languages[$i]['id'] . ']" ' . zen_set_field_length(TABLE_PRODUCTS_OPTIONS_VALUES, 'products_options_values_name', 25) . ' value="' . $value_name->fields['products_options_values_name'] . '"> <br />';
Code:$inputs .= $languages[$i]['code'] . ': <input type="text" name="value_name[' . $languages[$i]['id'] . ']" ' . zen_set_field_length(TABLE_PRODUCTS_OPTIONS_VALUES, 'products_options_values_name', 25) . ' value="' . zen_output_string($value_name->fields['products_options_values_name']) . '"> <br />';
Problem: Options Names with single and multiple quotes sometimes get truncated or cutoff
Solution:
Edit the file:
/admin/options_names_manager.php
change the lines around 616 - 618 from:
to read:Code:$inputs .= $languages[$i]['code'] . ': <input type="text" name="option_name[' . $languages[$i]['id'] . ']" ' . zen_set_field_length(TABLE_PRODUCTS_OPTIONS, 'products_options_name', 20) . ' value="' . $option_name->fields['products_options_name'] . '">' . TEXT_SORT . '<input type="text" name="products_options_sort_order[' . $languages[$i]['id'] . ']" size="3" value="' . $option_name->fields['products_options_sort_order'] . '"> <br />';
$inputs2 .= $languages[$i]['code'] . ': ' .
' ' . TEXT_OPTION_VALUE_COMMENTS . '<input type="text" name="products_options_comment[' . $languages[$i]['id'] . ']" size="50" value="' . $option_name->fields['products_options_comment'] . '">' .
Code:$inputs .= $languages[$i]['code'] . ': <input type="text" name="option_name[' . $languages[$i]['id'] . ']" ' . zen_set_field_length(TABLE_PRODUCTS_OPTIONS, 'products_options_name', 20) . ' value="' . zen_output_string($option_name->fields['products_options_name']) . '">' . TEXT_SORT . '<input type="text" name="products_options_sort_order[' . $languages[$i]['id'] . ']" size="3" value="' . $option_name->fields['products_options_sort_order'] . '"> <br />';
$inputs2 .= $languages[$i]['code'] . ': ' .
' ' . TEXT_OPTION_VALUE_COMMENTS . '<input type="text" name="products_options_comment[' . $languages[$i]['id'] . ']" size="50" value="' . zen_output_string($option_name->fields['products_options_comment']) . '">' .