Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix getTotalWeight Notice #10254
getTotalWeight function (Cart.php) can return "Notice: Undefined index: " if $products is null and $this->id is null to
getTotalWeight call updateProductWeight with null
but updateProductWeight return self::$_totalWeight[$productId] with $productId = 0 ($productId = (int) $productId);
so we retrun self::$_totalWeight but into getTotalWeight we return self::$_totalWeight[$this->id];
it's possible to solve this by changing return line
Your pull request description seems to be incomplete or malformed:
Would you mind completing the contribution table ? This would help us understand how interesting your contribution is.
(note: this is an automated message, but answering it will reach a real human )
As you said in your comment,
self::$_totalWeight[$this->id] is always defined, here thanks to
I guess it would be better to see how to reproduce this error. If there is a place in the core where we call the method without ID or product list, this must be fixed.
Also, if the value is only stored in the key
0 because of the int cast, why don't you add the same action on the return line?
return self::$_totalWeight[(int) $this->id];
Let us know if it removes the notice.