Skip to content

Commit 8b66c0c

Browse files
committed
Fix undefined array key 'price' error in Product::variantOptions()
Between October and November 2024, PHPUnit was upgraded from 10.x to 11.x, which introduced stricter error handling for undefined array keys. This caused tests to fail when accessing $variantOption['price'] for variant options that don't have a price key defined. The fix uses the null coalescing operator to provide a default null value when the 'price' key is not present, matching the pattern already used for the 'stock' key on line 139. This resolves 35 failing tests in the MigrateProductTypeTest suite and other tests that create variant options without price values.
1 parent 985528b commit 8b66c0c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Products/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function variantOptions(): Collection
133133
->key($variantOption['key'])
134134
->product($this)
135135
->name($variantOption['variant'])
136-
->price($variantOption['price'])
136+
->price($variantOption['price'] ?? null)
137137
->data(Arr::except($variantOption, ['key', 'variant', 'price', 'stock']));
138138

139139
if (isset($variantOption['stock'])) {

0 commit comments

Comments
 (0)