Closed (duplicate)
Project:
Ubercart
Version:
7.x-3.x-dev
Component:
Product kits
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 May 2012 at 19:22 UTC
Updated:
13 Jul 2012 at 08:58 UTC
I attempted to update a product kit by adding a new item, and received an error message for attempting to access a non-object, and a PDO exception with null values for quantity and discount. The offending code is in uc_product_kit.module (beginning line 269), which attempts to define a value for discount, then quantity from cascading if...else statements. The final statement in each case fails to test if the value is set, and causes the error. I corrected the error by putting a test in for the last value, and then defining a default in code:
elseif (isset($node->products[$nid]->discount)) {
$discount = $node->products[$nid]->discount;
} else {
$discount = 0;
}
if (isset($node->items)) {
if (!isset($node->items[$nid]['qty']) || $node->items[$nid]['qty'] === '') {
$node->items[$nid]['qty'] = 1;
}
$product->qty = $node->items[$nid]['qty'];
}
elseif (isset($node->products[$nid]->qty)) {
$product->qty = $node->products[$nid]->qty;
} else {
$product->qty = 1;
}
I have attached a patch for your review.
| Comment | File | Size | Author |
|---|---|---|---|
| uc_product_kit.patch | 1.33 KB | Triskelion |
Comments
Comment #1
tr commentedComment #2
muka commented+1 works for me, thank you
Comment #3
longwaveFixed in #1677876: Trying to get property of non-object in uc_product_kit_update() when adding extra products to a kit