From 553ad070cce2d40cc67a80402b9b3af396da07be Mon Sep 17 00:00:00 2001 From: mamazu <14860264+mamazu@users.noreply.github.com> Date: Thu, 9 Oct 2025 14:43:14 +0200 Subject: [PATCH 1/2] Fixing multiselect equls --- src/Traits/OrderItemCustomerOptionCapableTrait.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Traits/OrderItemCustomerOptionCapableTrait.php b/src/Traits/OrderItemCustomerOptionCapableTrait.php index 4d42e7ca..098a2325 100644 --- a/src/Traits/OrderItemCustomerOptionCapableTrait.php +++ b/src/Traits/OrderItemCustomerOptionCapableTrait.php @@ -110,7 +110,17 @@ public function equals(SyliusOrderItemInterface $item): bool // iterate over all options and compare their values foreach ($itemCustomerConfiguration as $code => $value) { - if ($curItemCustomerConfiguration[$code]->getOptionValue() !== $value->getOptionValue()) { + // Check that all multi select options are equal + if ($value->getCustomerOptionType() === CustomerOptionTypeEnum::MULTI_SELECT) { + if (!is_array($value) || count($value) !== count($curItemCustomerConfiguration[$code])) { + return false; + } + foreach ($curItemCustomerConfiguration[$code] as $optionKey => $multiSelectValue) { + if ($multiSelectValue->getOptionValue() !== $value[$optionKey]->getOptionValue()) { + return false; + } + } + } else if ($curItemCustomerConfiguration[$code]->getOptionValue() !== $value->getOptionValue()) { return false; } } From 11afcebaeb40487379215c4b93f0861f195b4f82 Mon Sep 17 00:00:00 2001 From: mamazu <14860264+mamazu@users.noreply.github.com> Date: Tue, 14 Oct 2025 19:15:03 +0200 Subject: [PATCH 2/2] Second try --- .../OrderItemCustomerOptionCapableTrait.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Traits/OrderItemCustomerOptionCapableTrait.php b/src/Traits/OrderItemCustomerOptionCapableTrait.php index 098a2325..b13272df 100644 --- a/src/Traits/OrderItemCustomerOptionCapableTrait.php +++ b/src/Traits/OrderItemCustomerOptionCapableTrait.php @@ -110,17 +110,28 @@ public function equals(SyliusOrderItemInterface $item): bool // iterate over all options and compare their values foreach ($itemCustomerConfiguration as $code => $value) { - // Check that all multi select options are equal - if ($value->getCustomerOptionType() === CustomerOptionTypeEnum::MULTI_SELECT) { - if (!is_array($value) || count($value) !== count($curItemCustomerConfiguration[$code])) { + // If one option is multi-select and the other one isn't they're not equal + if (is_array($value) !== is_array($curItemCustomerConfiguration[$code])) { + return false; + } + + // If it's multi-select + if (is_array($value)) { + if (count($value) !== count($curItemCustomerConfiguration[$code])) { return false; } + foreach ($curItemCustomerConfiguration[$code] as $optionKey => $multiSelectValue) { if ($multiSelectValue->getOptionValue() !== $value[$optionKey]->getOptionValue()) { return false; } } - } else if ($curItemCustomerConfiguration[$code]->getOptionValue() !== $value->getOptionValue()) { + + return false; + } + + // It's a normal value option + if ($curItemCustomerConfiguration[$code]->getOptionValue() !== $value->getOptionValue()) { return false; } }