<?php
/**
 * The Template for displaying all single products
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/single-product.php.
 *
 * @see         https://woocommerce.com/document/template-structure/
 * @package     WooCommerce\Templates
 * @version     1.6.4
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

get_header();

$product = wc_get_product( get_the_ID() );

if ( ! $product ) {
	return;
}

$product_id         = $product->get_id();
$product_title      = $product->get_title();
$product_short_desc = $product->get_short_description();
$sku                = $product->get_sku();

$rating_count = $product->get_rating_count();
$average      = $product->get_average_rating();

$categories    = get_the_terms( $product_id, 'product_cat' );
$main_category = ! empty( $categories ) && ! is_wp_error( $categories ) ? $categories[0] : null;

$attachment_ids  = $product->get_gallery_image_ids();
$main_image_id   = $product->get_image_id();
$all_images      = array();

if ( $main_image_id ) {
	$all_images[] = $main_image_id;
}
if ( ! empty( $attachment_ids ) ) {
	$all_images = array_merge( $all_images, $attachment_ids );
}

$attributes     = $product->get_attributes();
$size_attribute = null;

foreach ( $attributes as $attribute ) {
	$attr_name = $attribute->get_name();
	if ( false !== strpos( $attr_name, 'size' ) || false !== strpos( $attr_name, 'pa_size' ) ) {
		$size_attribute = $attribute;
	}
}

$related_products = wc_get_related_products( $product_id, 4 );

$comments = get_comments( array(
	'post_id' => $product_id,
	'status'  => 'approve',
	'type'    => 'review',
) );

$rating_distribution = array( 5 => 0, 4 => 0, 3 => 0, 2 => 0, 1 => 0 );
foreach ( $comments as $comment ) {
	$rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );
	if ( $rating >= 1 && $rating <= 5 ) {
		$rating_distribution[ $rating ]++;
	}
}

$price_html     = $product->get_price_html();
$current_price  = '';
$original_price = '';

if ( $product->is_type( 'variable' ) ) {
	$current_price = $price_html;
} elseif ( $product->is_on_sale() ) {
	if ( preg_match( '/<ins[^>]*>(.*?)<\/ins>/s', $price_html, $matches ) ) {
		$current_price = $matches[1];
	}
	if ( preg_match( '/<del[^>]*>(.*?)<\/del>/s', $price_html, $matches ) ) {
		$original_price = $matches[1];
	}
} else {
	$current_price = $price_html;
}

$badge_text = '';
$tag_text   = '';

if ( $product->is_on_sale() ) {
	$sale_pct   = ! $product->is_type( 'variable' ) ? shopbar_get_sale_percentage( $product ) : '';
	$badge_text = $sale_pct ? $sale_pct : esc_html__( 'Sale', 'shopbar' );
} elseif ( function_exists( 'shopbar_is_product_new' ) && shopbar_is_product_new( $product_id ) ) {
	$badge_text = esc_html__( 'New', 'shopbar' );
	$tag_text   = esc_html__( 'New Arrival', 'shopbar' );
} elseif ( $product->is_featured() ) {
	$tag_text = esc_html__( 'Bestseller', 'shopbar' );
}

$breadcrumb_items   = array();
$breadcrumb_items[] = array( 'label' => __( 'Home', 'shopbar' ), 'url' => home_url( '/' ) );

if ( $main_category ) {
	$breadcrumb_items[] = array( 'label' => $main_category->name, 'url' => get_term_link( $main_category ) );
}

$breadcrumb_items[] = array( 'label' => $product_title, 'url' => '' );
?>

<div class="shopbar-breadcrumb">
	<div class="shopbar-container">
		<nav class="shopbar-breadcrumb-nav">
			<?php foreach ( $breadcrumb_items as $i => $item ) : ?>
				<?php if ( ! empty( $item['url'] ) ) : ?>
					<a href="<?php echo esc_url( $item['url'] ); ?>" class="shopbar-breadcrumb-link"><?php echo esc_html( $item['label'] ); ?></a>
					<span class="shopbar-breadcrumb-sep">/</span>
				<?php else : ?>
					<span class="shopbar-breadcrumb-current"><?php echo esc_html( $item['label'] ); ?></span>
				<?php endif; ?>
			<?php endforeach; ?>
		</nav>
	</div>
</div>

<main class="shopbar-pdp-main">
	<div class="shopbar-container shopbar-pdp-container">
		<div class="shopbar-pdp-grid">

			<div class="shopbar-gallery">
				<div class="shopbar-gallery-main">
					<img id="mainImg" src="<?php echo ! empty( $all_images ) ? esc_url( wp_get_attachment_image_url( $all_images[0], 'large' ) ) : wc_placeholder_img_src(); ?>" alt="<?php echo esc_attr( $product_title ); ?>">
					<?php if ( $badge_text ) : ?>
						<div class="shopbar-pdp-badge <?php echo $product->is_on_sale() ? 'shopbar-badge-sale' : ( $product->is_featured() ? 'shopbar-badge-bestseller' : 'shopbar-badge-new' ); ?>"><?php echo esc_html( $badge_text ); ?></div>
					<?php endif; ?>
				</div>
				<?php if ( count( $all_images ) > 1 ) : ?>
				<div class="shopbar-gallery-thumbs">
					<?php foreach ( $all_images as $index => $image_id ) : ?>
						<button data-change-image="<?php echo intval( $index ); ?>" class="shopbar-thumb-btn <?php echo $index === 0 ? 'active' : ''; ?>" data-index="<?php echo intval( $index ); ?>" data-full="<?php echo esc_url( wp_get_attachment_image_url( $image_id, 'large' ) ); ?>">
							<img src="<?php echo esc_url( wp_get_attachment_image_url( $image_id, 'thumbnail' ) ); ?>" alt="<?php echo esc_attr( $product_title ) . ' ' . ( $index + 1 ); ?>">
						</button>
					<?php endforeach; ?>
				</div>
				<?php endif; ?>
			</div>

			<div class="shopbar-pdp-info">
				<?php shopbar_countdown_single(); ?>

				<?php if ( ! empty( $tag_text ) ) : ?>
					<span class="shopbar-pdp-tag"><?php echo esc_html( $tag_text ); ?></span>
				<?php endif; ?>

				<?php
				$pdp_brand = shopbar_get_product_brand( $product_id );
				if ( ! empty( $pdp_brand ) ) : ?>
					<p class="shopbar-pdp-brand"><?php echo esc_html( $pdp_brand ); ?></p>
				<?php endif; ?>

				<h1 class="shopbar-pdp-title"><?php echo esc_html( $product_title ); ?></h1>

				<?php if ( $rating_count > 0 ) : ?>
				<div class="shopbar-pdp-rating">
					<div class="shopbar-rating-stars">
						<?php for ( $i = 1; $i <= 5; $i++ ) : ?>
							<span class="shopbar-star-icon <?php echo $i <= round( $average ) ? 'shopbar-star-filled' : 'shopbar-star-empty'; ?>"><?php echo shopbar_svg_icon( 'star', 14 ); ?></span>
						<?php endfor; ?>
					</div>
					<a href="#reviews" class="shopbar-rating-link"><?php echo esc_html( number_format( $average, 1 ) ); ?> (<?php echo esc_html( $rating_count ); ?> <?php echo esc_html( _n( 'review', 'reviews', $rating_count, 'shopbar' ) ); ?>)</a>
				</div>
				<?php endif; ?>

				<div class="shopbar-pdp-price-block<?php echo $product->is_on_sale() ? ' is-on-sale' : ''; ?>" id="productPriceBlock">
					<?php if ( ! empty( $current_price ) ) : ?>
						<span class="shopbar-price-current"><?php echo wp_kses_post( $current_price ); ?></span>
					<?php endif; ?>
					<?php if ( ! empty( $original_price ) ) : ?>
						<span class="shopbar-price-original"><?php echo wp_kses_post( $original_price ); ?></span>
					<?php endif; ?>
				</div>

				<?php if ( $product_short_desc ) : ?>
					<p class="shopbar-pdp-desc"><?php echo wp_kses_post( $product_short_desc ); ?></p>
				<?php endif; ?>

				<?php if ( $product->is_type( 'variable' ) ) : ?>
					<div class="variations_form" data-product_id="<?php echo esc_attr( $product_id ); ?>">
						<script type="application/json" id="shopbar-variations-data"><?php echo wp_json_encode( $product->get_available_variations() ); ?></script>
						<?php
						$variations         = $product->get_available_variations();
						$var_attributes     = $product->get_variation_attributes();
						$default_attributes = $product->get_default_attributes();

						shopbar_single_swatches();

						foreach ( $var_attributes as $attribute_name => $options ) :
							$attribute_label = wc_attribute_label( $attribute_name );
							$selected_value  = isset( $default_attributes[ $attribute_name ] ) ? $default_attributes[ $attribute_name ] : '';
							?>
							<div class="shopbar-option-group" data-attribute-name="<?php echo esc_attr( $attribute_name ); ?>">
								<div class="shopbar-option-label"><?php echo esc_html( $attribute_label ); ?></div>
								<div class="shopbar-size-options">
									<?php
									$size_map = array(
										'small'              => 'S',
										'medium'             => 'M',
										'large'              => 'L',
										'extra small'        => 'XS',
										'extra large'        => 'XL',
										'double extra large' => 'XXL',
										'triple extra large' => 'XXXL',
									);

									foreach ( $options as $option ) :
										$option_slug = $option;
										if ( taxonomy_exists( $attribute_name ) ) {
											$term       = get_term_by( 'name', $option, $attribute_name );
											$option_slug = $term ? $term->slug : sanitize_title( $option );
										}

										$is_selected = ( $selected_value === $option || $selected_value === $option_slug );
										$is_oos      = false;

										foreach ( $variations as $variation ) {
											$attr_key = 'attribute_' . sanitize_title( $attribute_name );
											if ( isset( $variation['attributes'][ $attr_key ] ) && ( $variation['attributes'][ $attr_key ] === $option_slug || $variation['attributes'][ $attr_key ] === $option ) ) {
												$is_oos = ! $variation['is_in_stock'];
												break;
											}
										}

										$option_lower  = strtolower( $option );
										$size_abbrev   = isset( $size_map[ $option_lower ] ) ? $size_map[ $option_lower ] : $option;
										?>
										<button class="shopbar-size-btn <?php echo $is_selected ? 'active' : ''; ?> <?php echo $is_oos ? 'oos' : ''; ?>"
											data-attribute="<?php echo esc_attr( 'attribute_' . sanitize_title( $attribute_name ) ); ?>"
											data-value="<?php echo esc_attr( $option_slug ); ?>"
											data-display-name="<?php echo esc_attr( $option ); ?>"
											data-tooltip="<?php echo esc_attr( $option ); ?>"
											aria-label="<?php echo esc_attr( $option ); ?>"
											title="<?php echo esc_attr( $option ); ?>">
											<?php echo esc_html( $size_abbrev ); ?>
										</button>
									<?php endforeach; ?>
								</div>
								<?php shopbar_size_chart( 'button' ); ?>
							</div>
						<?php endforeach; ?>

						<div class="shopbar-variation-price" id="variationPriceDisplay" style="display:none;">
							<span class="shopbar-variation-price-current" id="variationPriceCurrent"></span>
							<span class="shopbar-variation-price-original" id="variationPriceOriginal"></span>
						</div>

						<form class="cart" method="post" enctype="multipart/form-data">
							<input type="hidden" name="product_id" value="<?php echo esc_attr( $product_id ); ?>">
							<input type="hidden" name="variation_id" value="" id="variation_id">
							<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
							<button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product_id ); ?>" class="single_add_to_cart_button alt" style="display:none!important"></button>
							<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
						</form>
					</div>
				<?php else : ?>
					<?php if ( $size_attribute && $size_attribute->get_visible() ) : ?>
					<div class="shopbar-option-group">
						<div class="shopbar-option-label"><?php esc_html_e( 'Size', 'shopbar' ); ?></div>
						<div class="shopbar-size-options">
							<?php
							$terms = wc_get_product_terms( $product_id, $size_attribute->get_name(), array( 'fields' => 'all' ) );
							foreach ( $terms as $term ) :
								?>
								<button class="shopbar-size-btn"
									data-size-name="<?php echo esc_attr( $term->name ); ?>"
									data-tooltip="<?php echo esc_attr( $term->name ); ?>"
									aria-label="<?php echo esc_attr( $term->name ); ?>"
									title="<?php echo esc_attr( $term->name ); ?>">
									<?php echo esc_html( $term->name ); ?>
								</button>
							<?php endforeach; ?>
						</div>
						<?php shopbar_size_chart( 'button' ); ?>
					</div>
					<?php endif; ?>

					<form class="cart" method="post" enctype="multipart/form-data" style="display:none">
						<input type="hidden" name="product_id" value="<?php echo esc_attr( $product_id ); ?>">
						<button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product_id ); ?>" class="single_add_to_cart_button alt"></button>
					</form>
				<?php endif; ?>

				<div class="shopbar-pdp-purchase">
					<div class="shopbar-qty-selector">
						<button class="shopbar-qty-btn" data-qty-change="-1">
							<?php echo shopbar_svg_icon( 'minus', 16 ); ?>
						</button>
						<input type="number" id="qtyValue" class="shopbar-qty-input" value="1" min="1">
						<button class="shopbar-qty-btn" data-qty-change="1">
							<?php echo shopbar_svg_icon( 'plus', 16 ); ?>
						</button>
					</div>
				<button class="shopbar-add-to-cart">
					<?php echo shopbar_svg_icon( 'shopping-bag', 18 ); ?>
					<span id="cartBtnText"><?php esc_html_e( 'Add to Cart', 'shopbar' ); ?></span>
				</button>
					<?php shopbar_wishlist_button(); ?>
				</div>

			<div class="shopbar-product-meta">
				<?php shopbar_trust_signals(); ?>
				<?php if ( $sku ) : ?>
					<span><?php esc_html_e( 'SKU:', 'shopbar' ); ?> <?php echo esc_html( $sku ); ?></span>
				<?php endif; ?>
			</div>

			<?php shopbar_product_tabs(); ?>
		</div>
		</div>
	</div>
</main>

<?php
$product_long_desc = $product->get_description();
$product_short_d  = $product->get_short_description();
$product_desc     = ! empty( $product_long_desc ) ? $product_long_desc : $product_short_d;

$has_additional_info = $product->has_attributes() || $product->has_weight() || $product->has_dimensions();
?>

<section class="shopbar-product-tabs-section">
	<div class="shopbar-container">
		<div class="shopbar-product-tabs<?php echo ! $has_additional_info ? ' shopbar-product-tabs--single' : ''; ?>">
			<div class="shopbar-tab-headers">
				<span class="shopbar-tab-header active-tab" data-tab="description"><?php esc_html_e( 'Description', 'shopbar' ); ?></span>
				<?php if ( $has_additional_info ) : ?>
					<span class="shopbar-tab-header" data-tab="additional"><?php esc_html_e( 'Additional information', 'shopbar' ); ?></span>
				<?php endif; ?>
			</div>
			<div class="shopbar-tab-panel active-panel" id="panel-description">
				<?php
				if ( $product_desc ) {
					echo wp_kses_post( wpautop( $product_desc ) );
				} else {
					echo '<p>' . esc_html__( 'A thoughtfully designed piece, crafted with quality materials and built to last.', 'shopbar' ) . '</p>';
				}
				?>
			</div>
			<?php if ( $has_additional_info ) : ?>
				<div class="shopbar-tab-panel" id="panel-additional">
					<?php wc_display_product_attributes( $product ); ?>
				</div>
			<?php endif; ?>
		</div>
	</div>
</section>

<section id="reviews" class="shopbar-reviews-section">
	<div class="shopbar-container">
		<div class="shopbar-reviews-grid">
			<div class="shopbar-reviews-summary">
				<h2 class="shopbar-reviews-title"><?php esc_html_e( 'Customer Reviews', 'shopbar' ); ?></h2>
				<div class="shopbar-reviews-score">
					<span class="shopbar-reviews-big-number"><?php echo esc_html( number_format( $average, 1 ) ); ?></span>
					<span class="shopbar-reviews-out-of"><?php esc_html_e( 'out of 5', 'shopbar' ); ?></span>
				</div>
				<div class="shopbar-reviews-stars">
					<?php for ( $i = 1; $i <= 5; $i++ ) : ?>
						<span class="shopbar-star-icon <?php echo $i <= round( $average ) ? 'shopbar-star-filled' : 'shopbar-star-empty'; ?>"><?php echo shopbar_svg_icon( 'star', 16 ); ?></span>
					<?php endfor; ?>
				</div>
				<p class="shopbar-reviews-based-on"><?php printf( esc_html__( 'Based on %d reviews', 'shopbar' ), $rating_count ); ?></p>

				<div class="shopbar-rating-bars">
					<?php for ( $i = 5; $i >= 1; $i-- ) :
						$percentage = $rating_count > 0 ? round( ( $rating_distribution[ $i ] / $rating_count ) * 100 ) : 0;
					?>
						<div class="shopbar-bar-row">
							<span class="shopbar-bar-label"><?php echo esc_html( $i ); ?></span>
							<div class="shopbar-bar-track">
								<div class="shopbar-bar-fill" style="width:<?php echo esc_attr( $percentage ); ?>%"></div>
							</div>
							<span class="shopbar-bar-count"><?php echo esc_html( $percentage ); ?>%</span>
						</div>
					<?php endfor; ?>
				</div>

				<button class="shopbar-write-review-btn" id="writeReviewBtn"><?php esc_html_e( 'Write a Review', 'shopbar' ); ?></button>
			</div>

			<div class="shopbar-reviews-list">
				<?php if ( ! empty( $comments ) ) : ?>
					<?php
					$review_index = 0;
					foreach ( $comments as $comment ) :
						$comment_rating  = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );
						$comment_author  = $comment->comment_author;
						$comment_content = $comment->comment_content;

						$review_title = '';
						$review_text  = $comment_content;
						if ( preg_match( '/<strong>(.*?)<\/strong>\s*\n\s*\n(.*)/s', $comment_content, $matches ) ) {
							$review_title = $matches[1];
							$review_text  = $matches[2];
						}

						$comment_time = human_time_diff( get_comment_time( 'U' ), time() );
						$is_hidden    = $review_index >= 3;
					?>
						<div class="shopbar-review-card<?php echo $is_hidden ? ' shopbar-review-hidden' : ''; ?>"<?php echo $is_hidden ? ' style="display:none"' : ''; ?>>
							<div class="shopbar-review-top">
								<div>
									<div class="shopbar-review-stars">
										<?php for ( $s = 1; $s <= 5; $s++ ) : ?>
											<span class="shopbar-star-icon <?php echo $s <= $comment_rating ? 'shopbar-star-filled' : 'shopbar-star-empty'; ?>"><?php echo shopbar_svg_icon( 'star', 14 ); ?></span>
										<?php endfor; ?>
									</div>
									<?php if ( ! empty( $review_title ) ) : ?>
										<p class="shopbar-review-title"><?php echo esc_html( $review_title ); ?></p>
									<?php endif; ?>
								</div>
								<span class="shopbar-review-verified"><?php esc_html_e( 'Verified', 'shopbar' ); ?></span>
							</div>
							<p class="shopbar-review-text"><?php echo wp_kses_post( $review_text ); ?></p>
							<div class="shopbar-review-author">
								<div class="shopbar-author-avatar">
									<?php echo wp_kses_post( get_avatar( $comment->comment_author_email, 32, '', $comment_author, array( 'class' => 'shopbar-avatar-img' ) ) ); ?>
								</div>
								<div>
									<p class="shopbar-author-name"><?php echo esc_html( $comment_author ); ?></p>
									<p class="shopbar-author-meta"><?php printf( esc_html__( '%s ago', 'shopbar' ), esc_html( $comment_time ) ); ?></p>
								</div>
							</div>
						</div>
					<?php
						$review_index++;
					endforeach;
					?>
				<?php else : ?>
					<p class="shopbar-no-reviews"><?php esc_html_e( 'No reviews yet. Be the first to review this product!', 'shopbar' ); ?></p>
				<?php endif; ?>
			</div>
		</div>

		<?php if ( count( $comments ) > 3 ) : ?>
			<button class="shopbar-load-more-reviews" id="loadMoreReviews" data-per-page="3"><?php esc_html_e( 'Load More Reviews', 'shopbar' ); ?></button>
		<?php endif; ?>
	</div>
</section>

<div class="shopbar-review-modal" id="reviewModal">
	<div class="shopbar-review-modal-overlay" id="reviewModalOverlay"></div>
	<div class="shopbar-review-modal-content">
		<button class="shopbar-review-modal-close" id="reviewModalClose">
			<?php echo shopbar_svg_icon( 'x', 20 ); ?>
		</button>
		<div class="shopbar-review-modal-header">
			<h3><?php esc_html_e( 'Write a Review', 'shopbar' ); ?></h3>
			<p><?php esc_html_e( 'Share your experience with this product', 'shopbar' ); ?></p>
		</div>
		<form class="shopbar-review-form" id="reviewForm" method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
			<input type="hidden" name="action" value="shopbar_submit_review">
			<input type="hidden" name="product_id" value="<?php echo esc_attr( $product_id ); ?>">
			<?php wp_nonce_field( 'shopbar_submit_review', 'shopbar_review_nonce' ); ?>

			<div class="shopbar-form-group">
				<label><?php esc_html_e( 'Your Rating', 'shopbar' ); ?></label>
				<div class="shopbar-star-rating-input" id="starRatingInput">
					<span class="star" data-rating="5"><?php echo shopbar_svg_icon( 'star', 24 ); ?></span>
					<span class="star" data-rating="4"><?php echo shopbar_svg_icon( 'star', 24 ); ?></span>
					<span class="star" data-rating="3"><?php echo shopbar_svg_icon( 'star', 24 ); ?></span>
					<span class="star" data-rating="2"><?php echo shopbar_svg_icon( 'star', 24 ); ?></span>
					<span class="star" data-rating="1"><?php echo shopbar_svg_icon( 'star', 24 ); ?></span>
					<input type="hidden" name="rating" id="ratingInput" value="">
				</div>
			</div>

			<div class="shopbar-form-group">
				<label for="reviewTitle"><?php esc_html_e( 'Review Title', 'shopbar' ); ?></label>
				<input type="text" id="reviewTitle" name="review_title" placeholder="<?php esc_attr_e( 'Give your review a title', 'shopbar' ); ?>" required>
			</div>

			<div class="shopbar-form-group">
				<label for="reviewContent"><?php esc_html_e( 'Your Review', 'shopbar' ); ?></label>
				<textarea id="reviewContent" name="review_content" rows="5" placeholder="<?php esc_attr_e( 'What did you like or dislike?', 'shopbar' ); ?>" required></textarea>
			</div>

			<div class="shopbar-form-row">
				<div class="shopbar-form-group">
					<label for="reviewerName"><?php esc_html_e( 'Your Name', 'shopbar' ); ?></label>
					<input type="text" id="reviewerName" name="reviewer_name" placeholder="<?php esc_attr_e( 'Enter your name', 'shopbar' ); ?>" required>
				</div>
				<div class="shopbar-form-group">
					<label for="reviewerEmail"><?php esc_html_e( 'Email', 'shopbar' ); ?></label>
					<input type="email" id="reviewerEmail" name="reviewer_email" placeholder="<?php esc_attr_e( 'Enter your email', 'shopbar' ); ?>" required>
				</div>
			</div>

			<button type="submit" class="shopbar-submit-review"><?php esc_html_e( 'Submit Review', 'shopbar' ); ?></button>
		</form>
	</div>
</div>

<?php if ( ! empty( $related_products ) ) : ?>
<section class="shopbar-related-section">
	<div class="shopbar-container">
		<h2 class="shopbar-related-title"><?php esc_html_e( 'You may also like', 'shopbar' ); ?></h2>
		<ul class="products columns-4">
			<?php
			foreach ( $related_products as $related_id ) :
				$related_post = get_post( $related_id );
				if ( ! $related_post ) {
					continue;
				}
				setup_postdata( $related_post );
				$related_obj = wc_get_product( $related_id );
				if ( ! $related_obj ) {
					continue;
				}
				$GLOBALS['product'] = $related_obj;
				wc_get_template_part( 'content', 'product' );
			endforeach;
			wp_reset_postdata();
			?>
		</ul>
	</div>
</section>
<?php endif; ?>

<?php shopbar_size_chart( 'modal' ); ?>

<div id="lightbox" class="shopbar-lightbox">
	<button class="shopbar-lightbox-close"><?php echo shopbar_svg_icon( 'x', 24 ); ?></button>
	<img id="lightboxImg" src="" alt="<?php esc_attr_e( 'Zoom', 'shopbar' ); ?>">
</div>

<button id="scrollTop" class="shopbar-scroll-top">
	<?php echo shopbar_svg_icon( 'chevron-up', 20 ); ?>
</button>

<?php get_footer(); ?>
