Closed ajenkins-dev closed 1 year ago
This is on the latest releases of ConcreteCMS 9.1.3 and Community Store, running on PHP 8.0.25.
The error occurs when adding an item to the cart that has no variations and when it's stock is limited.
Undefined array key "variation" /packages/community_store/src/CommunityStore/Cart/Cart.php
if ($stockLimited) { if ($cartitem['product']['variation']) { if (!isset($stockTotals['variations'][$cartitem['product']['variation']])) { $stockTotals['variations'][$cartitem['product']['variation']] = ['cartQuantity' => $cartitem['product']['qty'], 'maxQuantity' => $maxQuantity]; } else { $stockTotals['variations'][$cartitem['product']['variation']]['cartQuantity'] += $cartitem['product']['qty']; } } else { if (!isset($stockTotals['products'][$cartitem['product']['pID']])) { $stockTotals['products'][$cartitem['product']['pID']] = ['cartQuantity' => $cartitem['product']['qty'], 'maxQuantity' => $maxQuantity]; } else { $stockTotals['products'][$cartitem['product']['pID']]['cartQuantity'] += $cartitem['product']['qty']; } } }
I changed it to:
if ($stockLimited) { if (isset($cartitem['product']['variation'])) { if (!isset($stockTotals['variations'][$cartitem['product']['variation']])) { $stockTotals['variations'][$cartitem['product']['variation']] = ['cartQuantity' => $cartitem['product']['qty'], 'maxQuantity' => $maxQuantity]; } else { $stockTotals['variations'][$cartitem['product']['variation']]['cartQuantity'] += $cartitem['product']['qty']; } } else { if (!isset($stockTotals['products'][$cartitem['product']['pID']])) { $stockTotals['products'][$cartitem['product']['pID']] = ['cartQuantity' => $cartitem['product']['qty'], 'maxQuantity' => $maxQuantity]; } else { $stockTotals['products'][$cartitem['product']['pID']]['cartQuantity'] += $cartitem['product']['qty']; } } }
and it seems to have resolved the issue.
Thank you for this, wasn't one I was going to pick up easily. I've pushed up a fix.
This is on the latest releases of ConcreteCMS 9.1.3 and Community Store, running on PHP 8.0.25.
The error occurs when adding an item to the cart that has no variations and when it's stock is limited.
Undefined array key "variation" /packages/community_store/src/CommunityStore/Cart/Cart.php
I changed it to:
and it seems to have resolved the issue.