get_type() === 'variable' && ! $blocksy_current_variation) { $default_attributes = $product->get_default_attributes(); $is_default_variation = false; foreach($product->get_available_variations() as $variation_values ) { foreach ($variation_values['attributes'] as $key => $attribute_value) { $attribute_name = str_replace( 'attribute_', '', $key ); $default_value = $product->get_variation_default_attribute($attribute_name); if ($default_value == $attribute_value) { $is_default_variation = true; } else { $is_default_variation = false; break; } } if ($is_default_variation ) { $variation_id = $variation_values['variation_id']; break; } } if ($is_default_variation) { $default_variation = wc_get_product($variation_id); $blocksy_current_variation = $default_variation; } $maybe_variation = (new \WC_Product_Data_Store_CPT())->find_matching_product_variation( $product, $_GET ); if ($maybe_variation) { $blocksy_current_variation = wc_get_product($maybe_variation); } } $is_single = is_single(); if (isset($forced_single) && $forced_single) { $is_single = true; } if (! isset($gallery_images)) { $thumb_id = apply_filters( 'woocommerce_product_get_image_id', get_post_thumbnail_id($product->get_id()), $product ); $thumb_id = get_post_thumbnail_id($product->get_id()); $gallery_images = $product->get_gallery_image_ids(); if ($thumb_id) { array_unshift($gallery_images, intval($thumb_id)); } else { $gallery_images = [null]; } } $product_view_attr = [ 'class' => 'woocommerce-product-gallery' ]; $active_index = 1; if ($blocksy_current_variation) { $variation_main_image = $blocksy_current_variation->get_image_id(); $variation_values = get_post_meta( $blocksy_current_variation->get_id(), 'blocksy_post_meta_options' ); if (empty($variation_values)) { $variation_values = [[]]; } $variation_values = $variation_values[0]; $variation_gallery_images = blocksy_akg('images', $variation_values, []); $gallery_source = blocksy_akg('gallery_source', $variation_values, 'default'); if ($gallery_source === 'default') { if (! in_array($variation_main_image, $gallery_images)) { $gallery_images[0] = $variation_main_image; } else { $active_index = array_search( $variation_main_image, $gallery_images ) + 1; } } else { $gallery_images = [$variation_main_image]; foreach ($variation_gallery_images as $variation_gallery_image) { $gallery_images[] = $variation_gallery_image['attachment_id']; } } $product_view_attr[ 'data-current-variation' ] = $blocksy_current_variation->get_id(); } $gallery_images = apply_filters( 'blocksy:woocommerce:product-view:product_gallery_images', $gallery_images ); $ratio = '3/4'; $single_ratio = get_theme_mod('product_gallery_ratio', '3/4'); global $blocksy_is_quick_view; if (! $blocksy_is_quick_view) { $product_view_attr = apply_filters( 'blocksy:woocommerce:product-view:attr', $product_view_attr ); } ob_start(); echo '
'; if ($product->is_in_stock()) { if (get_theme_mod('has_product_single_onsale', 'yes') === 'yes') { woocommerce_show_product_sale_flash(); } } else { echo blocksy_get_woo_out_of_stock_badge([ 'location' => 'single' ]); } $maybe_custom_content = null; if (! $blocksy_is_quick_view) { $maybe_custom_content = apply_filters( 'blocksy:woocommerce:product-view:content', null, $product, $gallery_images, $is_single ); } do_action('blocksy:woocommerce:product-view:start'); $gallery_actions = []; if ( get_theme_mod('has_product_single_lightbox', 'no') === 'yes' && get_theme_mod('has_product_single_zoom', 'yes') === 'yes' && ! isset($blocksy_is_quick_view) && ! $blocksy_is_quick_view && isset($gallery_images[0]) && $gallery_images[0] && ! $maybe_custom_content && apply_filters('blocksy:woocommerce:product-review:has-gallery-zoom-trigger', true) ) { $gallery_actions[] = '🔍'; } if (! empty($gallery_actions)) { // echo ''; } $default_ratio = apply_filters('blocksy:woocommerce:default_product_ratio', '3/4'); if (! $maybe_custom_content && count($gallery_images) === 1) { $attachment_id = $gallery_images[0]; $image_href = wp_get_attachment_image_src( $attachment_id, 'full' ); $width = null; $height = null; if ($image_href) { $width = $image_href[1]; $height = $image_href[2]; $image_href = $image_href[0]; } echo blocksy_image([ 'no_image_type' => 'woo', 'attachment_id' => $gallery_images[0], 'post_id' => $product->get_id(), 'size' => 'woocommerce_single', 'ratio' => $is_single ? $single_ratio : $default_ratio, 'tag_name' => 'a', 'size' => 'woocommerce_single', 'html_atts' => array_merge([ 'href' => $image_href ], $width ? [ 'data-width' => $width, 'data-height' => $height ] : []), 'display_video' => true ]); } if (! $maybe_custom_content && count($gallery_images) > 1) { echo blocksy_flexy( apply_filters( 'blocksy:woocommerce:single_product:flexy-args', [ 'active_index' => $active_index, 'images' => $gallery_images, 'size' => 'woocommerce_single', 'pills_images' => $is_single ? $gallery_images : null, 'images_ratio' => $is_single ? $single_ratio : $default_ratio ] ) ); } if ($maybe_custom_content) { echo $maybe_custom_content; } do_action('blocksy:woocommerce:product-view:end'); do_action('woocommerce_product_thumbnails'); echo '
'; $result_html = ob_get_clean(); echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $result_html, $gallery_images[0] );