@php /** * @name Pagina prodotto\Dettagli\Aggiungi al carrello\Prodotto con varianti\Prodotto con due variazioni * @version 1.0.0 */ @endphp @php $variations_color_description = call_setting('settings.product.variations_color_description'); if(is_customer()){ $variations_color_description = call_setting('settings.product.variations_color_description_customers'); } if(is_agent()){ $variations_color_description = call_setting('settings.product.variations_color_description_agents'); } $only_instock = false; if(!is_agent()){ $only_instock = call_setting('settings.product.only_instock'); } @endphp @foreach ( $variations as $variation ) @php $main_attribute = $variation->get_attributes(); $main_term = $main_attribute->get_term(); $main_type = $main_attribute->get_type(); $attribute = $variation->get_attributes()->get_subterms(); $type = $attribute->get_type(); $terms = $attribute->get_terms(); if($only_instock){ if(!$main_term->in_stock() && !$main_term->in_cart()){ continue; } } @endphp
@php $main_term_type = 'text'; $nocolor = false; if($main_type == 'color'){ $main_term_type = 'color'; $color = $variation->get_color(); if(!empty($color)){ $main_term_type = $color->get_type(); $color = $color->get_color(); }else{ $nocolor = true; $color = ''; } } $image = $variation->get_images(); $image_data = ''; $class_main_term = ['product-attribute', 'product-attribute-type-' . $main_type, 'attr-' . $main_term_type, 'attr-' . $main_term->get_slug()]; $zoom_variations = call_setting('settings.product.variations_zoom_' . get_user_type()); if($zoom_variations){ if( !$nocolor && $main_term_type == 'image' ){ $class_main_term[] = 'attr-zoom-image'; $image_data = ' data-fancybox="zoom-product-attr-' . $product->get_id(). '" data-src=' . $color; } }else{ if(!empty($image)){ $image = $image[0]; $class_main_term[] = 'attr-link-image'; $image_data = ' data-image-id="'.$image->get_id().'"'; } } if($nocolor){ $class_main_term[] = 'attr-color-not-found'; } if($variations_color_description == 'yes' && $main_type == 'color'){ $class_main_term[] = 'product-attribute-color-description'; } @endphp
@if($main_term_type == 'text') {{ $main_term->get_name_html() }} @endif @if($main_term_type == 'hex')
@endif @if($main_term_type == 'image')
@endif @if($variations_color_description == 'yes' && $main_type == 'color') {{ $main_term->get_name_html() }} @endif
@foreach ($terms as $term) @php if($only_instock){ if(!$term->in_stock() && !$term->in_cart()){ continue; } } $term_type = 'text'; $class_term = ['product-term', 'product-term-' . $term->get_slug()]; $nocolor = false; if($type == 'color'){ $term_type = 'color'; $color = $term->get_color(); if(!empty($color)){ $term_type = $color->get_type(); $color = $color->get_color(); }else{ $nocolor = true; $color = ''; } $class_term[] = 'product-term-' . $term_type; }else{ $class_term[] = 'product-term-text'; } if($nocolor){ $class_term[] = 'attr-color-not-found'; } @endphp
@if($type == 'color') @if($term_type == 'hex')
@endif @if($term_type == 'image')
@endif @else
{{ $term->get_name() }}
@endif @if(current_cart() !== false)
@do_action( "product_quantity_field", $variation) @php $stock = $term->get_stock(); $stock_quantity = (!empty($stock)) ? (int)$stock->get_quantity() : 0; $field_class = ['form-control', 'input-quantity', 'check-quantity']; if(is_customer()){ $field_class[] = 'check-quantity-stock'; } if(!$term->is_visible()){ $field_class[] = 'check-visibility'; $stock_quantity = 0; } $field_set = [ 'class' => implode(' ', $field_class), 'id' => 'quantity-'.$product->get_id().'-'.$term->get_slug(), 'current-quantity' => ($term->in_cart()) ? $term->get_quantity() : 0, 'stock-quantity' => $stock_quantity, 'min' => 0 ]; if(is_customer() || !$term->is_visible()){ $field_set['max'] = $stock_quantity; } @endphp {!! Form::text('quantity['.$variation->get_id($term).']', ($term->in_cart()) ? $term->get_quantity() : 0, $field_set) !!} @do_action( "product_quantity_field_after", $variation)
@endif
@endforeach
@endforeach