diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php b/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php index 5178f26e1dc93..5d166ec882875 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php @@ -76,7 +76,9 @@ public function execute(Quote $cart, int $cartItemId, float $qty, array $customi $customizableOptions = []; foreach ($customizableOptionsData as $customizableOption) { - $customizableOptions[$customizableOption['id']] = $customizableOption['value_string']; + $customizableOptions[$customizableOption['id']] = $this->convertCustomOptionValue( + $customizableOption['value_string'] + ); } try { @@ -174,4 +176,23 @@ private function createBuyRequest(float $qty, array $customOptions): DataObject ], ]); } + + // TODO: Refactor the code duplication with addCartItem + // TODO: Make a reusable logic that is shared between add to cart / change cart approaches + + /** + * Convert custom options vakue + * + * @param string $value + * @return string|array + */ + private function convertCustomOptionValue(string $value) + { + $value = trim($value); + if (substr($value, 0, 1) === "[" && + substr($value, strlen($value) - 1, 1) === "]") { + return explode(',', substr($value, 1, -1)); + } + return $value; + } }