/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartItemOptionsFromUID.php
49 строк
2 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 10:44
22 окт 2025, 10:44
264bea2
Код
Авторство
О чём код?
<?php /** * Copyright 2020 Adobe * All Rights Reserved. */ declare(strict_types=1); namespace Magento\GraphQl\Quote; /** * Extracts cart item options from UID */ class GetCartItemOptionsFromUID { /** * Gets an array of encoded item options with UID, extracts and decodes the values * * @param array $encodedCustomOptions * @return array */ public function execute(array $encodedCustomOptions): array { $customOptions = []; foreach ($encodedCustomOptions['selected_options'] as $selectedOption) { [$optionType, $optionId, $optionValueId] = explode('/', base64_decode($selectedOption)); if ($optionType == 'custom-option') { if (isset($customOptions[$optionId])) { $customOptions[$optionId] = [$customOptions[$optionId], $optionValueId]; } else { $customOptions[$optionId] = $optionValueId; } } } foreach ($encodedCustomOptions['entered_options'] as $enteredOption) { /* The date normalization is required since the attribute might value is formatted by the system */ if ($enteredOption['type'] === 'date') { $enteredOption['value'] = date('M d, Y', strtotime($enteredOption['value'])); } [$optionType, $optionId] = explode('/', base64_decode($enteredOption['uid'])); if ($optionType == 'custom-option') { $customOptions[$optionId] = $enteredOption['value']; } } return $customOptions; } }