@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
@if ($isDefaultLanguage)
{{ trans('plugins/ecommerce::product-option.add_new_option') }}
@if (! empty($globalOptions))
{{ trans('plugins/ecommerce::product-option.add_global_option') }}
@endif @else
{{ trans('plugins/ecommerce::product-option.no_global_options') }}
@endif
@push('footer')
@if ($isDefaultLanguage) @endif @if ($isDefaultLanguage) @endif
__priceLabel__ __priceTypeLabel__
@if ($isDefaultLanguage) @endif @if ($isDefaultLanguage) @endif __optionValue__
#__label____priceLabel__ __priceTypeLabel__
@if ($isDefaultLanguage) @endif @if ($isDefaultLanguage) @endif

__nameLabel__
@if ($isDefaultLanguage)
__optionTypeLabel__
@endif
@if ($isDefaultLanguage)
__pricePerProductHelper__
@endif
__optionValueSortable__
@endpush