duncanmcclean / simple-commerce

A simple, yet powerful e-commerce addon for Statamic.
https://statamic.com/addons/duncanmcclean/simple-commerce
Other
147 stars 41 forks source link

Fix updating variant line items #846

Closed duncanmcclean closed 1 year ago

duncanmcclean commented 1 year ago

This pull request fixes a bug where line items with variant products couldn't be updated - an error was being thrown.

It was happening as the controller was expecting $lineItem->variant() to be a string (the key of the variant) but it was returning an array like this:

[
    'product' => 'id-of-the-product',
    'variant' => 'Red_Large',
]

From what I can tell, $lineItem->variant() hasn't been returning a string since v2.1 (97737d2) - I'm surprised it hasn't been brought up before now to be honest 😅

The tests haven't picked this issue up as the line items data was still using the old format (a string) which worked for the code. I've adjusted the tests, they failed & I've fixed the bug.

Fixes #844

github-actions[bot] commented 1 year ago

Released as part of v4.5.6.