@php Assets::addScriptsDirectly('vendor/core/plugins/ecommerce/js/product-option.js'); $refLang = request()->input('ref_lang'); $isDefaultLanguage = !defined('LANGUAGE_ADVANCED_MODULE_SCREEN_NAME') || !$refLang || $refLang == Language::getDefaultLocaleCode(); $withRelations = ['values']; if (!$isDefaultLanguage) { $withRelations = array_merge($withRelations, ['translations', 'values.translations']); } $product = $product->loadMissing([ 'options' => function ($query) use ($withRelations) { return $query->with($withRelations); }, ]); $oldOption = old('options', []) ?? []; $currentProductOption = $product->options; if (! empty($currentProductOption) && $currentProductOption instanceof ArrayAccess) { foreach ($currentProductOption as $key => $option) { $optionName = $option->name; if (!$isDefaultLanguage && $refLang) { $translation = $option->translations?->firstWhere('lang_code', $refLang); if ($translation && $translation->name) { $optionName = $translation->name; } } $currentProductOption[$key]['name'] = $optionName; if ($option->values && $option->values->isNotEmpty()) { foreach ($option->values as $valueKey => $value) { $optionValue = $value->option_value; if (!$isDefaultLanguage && $refLang) { $valueTranslation = $value->translations?->firstWhere('lang_code', $refLang); if ($valueTranslation && $valueTranslation->option_value) { $optionValue = $valueTranslation->option_value; } } $currentProductOption[$key]['values'][$valueKey]['option_value'] = $optionValue; } } } } if (! empty($oldOption)) { $currentProductOption = $oldOption; } @endphp @push('header') @endpush
| __priceLabel__ | __priceTypeLabel__ | @endif|
|---|---|---|
| @endif | ||
| # | @endif__label__ | @if ($isDefaultLanguage)__priceLabel__ | __priceTypeLabel__ | @endif|
|---|---|---|---|---|