You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
652 lines
23 KiB
652 lines
23 KiB
<?php
|
|
/**
|
|
* The Template for displaying all single products.
|
|
*
|
|
* Override this template by copying it to yourtheme/woocommerce/single-product.php
|
|
*
|
|
* @author WooThemes
|
|
* @package WooCommerce/Templates
|
|
* @version 1.6.4
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
|
|
|
|
$loc = pll_current_language();
|
|
if ($loc == 'en'){
|
|
get_header('gp_eng');
|
|
$cur_symb = '$';
|
|
}
|
|
else{
|
|
get_header('gp');
|
|
$cur_symb = '₽';
|
|
}
|
|
|
|
global $product;
|
|
// Get content width and sidebar position.
|
|
$product_id = $product->get_id();
|
|
$content_class = woodmart_get_content_class();
|
|
$weight_list = [];
|
|
$is_sale = false;
|
|
if ($product->get_sale_price()){
|
|
$is_sale = true;
|
|
}
|
|
$var_gallery = array();
|
|
$var_img = '';
|
|
$gallery = $product->get_gallery_image_ids();
|
|
if ($product->get_type() == 'variable'){
|
|
|
|
|
|
$available_variations = $product->get_available_variations();
|
|
$var_first = $variation_obj = new WC_Product_Variation($available_variations[0]['variation_id']);
|
|
$choosen_var = (isset($_GET['attribute_pa_weight'])) ? $_GET['attribute_pa_weight'] : $var_first->get_attributes()['pa_weight'];
|
|
$var_id = '';
|
|
$choosen_stock = 0;
|
|
foreach( $available_variations as $variation ) {
|
|
$variation_obj = new WC_Product_Variation($variation['variation_id']);
|
|
if( $variation_obj->has_weight() ) {
|
|
$weight = $variation_obj->get_weight();
|
|
$attr = $variation_obj->get_attributes()['pa_weight'];
|
|
$is_choosen = $choosen_var == $attr;
|
|
$stock = $variation_obj->get_stock_quantity();
|
|
$additional = $variation['additional_variation_images'];
|
|
if($is_choosen){
|
|
$var_id = $variation_obj->get_id();
|
|
$choosen_stock = $stock;
|
|
$var_gallery = $additional;
|
|
$var_img = $variation['image']['src'];
|
|
}
|
|
if ($variation_obj->get_sale_price()){
|
|
$is_sale = true;
|
|
}
|
|
?>
|
|
|
|
<?php $weight_list[] = array(
|
|
'weight'=> $weight,
|
|
'price'=> $variation_obj->get_price(),
|
|
'sale_price' => $variation_obj->get_sale_price(),
|
|
'regular_price' => $variation_obj->get_regular_price(),
|
|
'id'=> $variation_obj->get_id(),
|
|
'is_chosen' => $is_choosen,
|
|
'attr' => $attr,
|
|
|
|
'stock' => $stock,
|
|
'url' => get_permalink( $variation_obj->get_id() ),
|
|
);
|
|
}
|
|
}}
|
|
|
|
|
|
else {
|
|
$choosen_stock = $product->get_stock_quantity();
|
|
}
|
|
$soon = wc_get_product_terms( get_the_ID(), 'pa_soon' );
|
|
foreach ($soon as $term) {
|
|
if($term -> name){
|
|
$choosen_stock = false;
|
|
?>
|
|
<? };
|
|
|
|
}
|
|
?>
|
|
|
|
|
|
<main class="wrapper">
|
|
<div class="breadcrumbs">
|
|
<a href="<?php echo home_url() ?>" class="breadcrumbs__item">
|
|
<?php echo esc_html__( 'main', 'woodmart' ) ?>
|
|
</a>
|
|
<a href="<?php echo get_permalink( wc_get_page_id( 'shop' ) ) ?>" class="breadcrumbs__item">
|
|
<?php echo esc_html__( 'products', 'woodmart' ) ?>
|
|
</a>
|
|
<?php
|
|
$list = get_the_terms( $product->get_ID(), 'product_cat', '', ', ' );
|
|
|
|
?>
|
|
<a href="<?php echo get_term_link($list[0]->slug, 'product_cat') ?>" class="breadcrumbs__item">
|
|
<?php echo mb_strtolower($list[0]->name) ?>
|
|
</a>
|
|
</div>
|
|
|
|
<a href="<?php echo get_permalink( wc_get_page_id( 'shop' ) ) ?>" class="back back-detail">
|
|
back
|
|
</a>
|
|
<?php $post_thumbnail_id = $product->get_image_id(); ?>
|
|
<?php
|
|
if ($product->get_type() == 'variable'):
|
|
?>
|
|
|
|
<div class="detail">
|
|
<div class="detail__images">
|
|
|
|
<?php if( $var_gallery ) :
|
|
$i = 1;
|
|
|
|
?>
|
|
|
|
|
|
<?php foreach( $var_gallery as $product_gallery_id ) : ?>
|
|
|
|
<?php
|
|
$class = $product_gallery_id['class'];
|
|
if (!$class){
|
|
$class = 'detail__image--width-perc-50';
|
|
}
|
|
?>
|
|
<div class="detail__image <?php echo $class ?>" data-count-img="<?php echo $i; ?>">
|
|
<img src="<?php echo $product_gallery_id['src'] ?>" alt="">
|
|
</div>
|
|
<?php
|
|
$i++;
|
|
endforeach; ?>
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<div class="swiper-pagination"></div>
|
|
|
|
</div>
|
|
<?php
|
|
else:
|
|
?>
|
|
<?php $post_thumbnail_id = $product->get_image_id(); ?>
|
|
|
|
<div class="detail">
|
|
<div class="detail__images">
|
|
<div class="detail__image detail__image--width-perc-100" data-count-img="0">
|
|
|
|
|
|
<img src="<?php echo wp_get_attachment_url( $post_thumbnail_id ); ?>" alt="" class="">
|
|
</div>
|
|
|
|
<?php if( $gallery ) :
|
|
$i = 1;
|
|
|
|
?>
|
|
|
|
|
|
<?php foreach( $gallery as $product_gallery_id ) : ?>
|
|
|
|
<?php
|
|
$class = get_field('class', $product_gallery_id);
|
|
if (!$class){
|
|
$class = 'detail__image--width-perc-50';
|
|
}
|
|
?>
|
|
<div class="detail__image <?php echo $class ?>" data-count-img="<?php echo $i; ?>">
|
|
<?php echo wp_get_attachment_image( $product_gallery_id, 'woocommerce_single' ) ?>
|
|
</div>
|
|
<?php
|
|
$i++;
|
|
endforeach; ?>
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<div class="swiper-pagination"></div>
|
|
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
|
|
<div class="detail__content">
|
|
<div class="detail__label">
|
|
<div class="detail__label-wrap">
|
|
|
|
|
|
<?php
|
|
|
|
$tags = wc_get_product_terms( get_the_ID(), 'pa_catalog_tags' );
|
|
|
|
|
|
?>
|
|
<?php
|
|
foreach ($tags as $tag) {
|
|
?>
|
|
<div class="product-item-label__tag product-item-label__tag--black">
|
|
<?php echo $tag -> name ?>
|
|
</div>
|
|
<?php
|
|
}
|
|
?>
|
|
<?php if (strpos($product->get_name(), 'COSMODOG') !== false): ?>
|
|
<div class="product-item-label__tag product-item-label__tag--title">
|
|
COSMODOG
|
|
</div>
|
|
<?php elseif (strpos($product->get_name(), 'COSMOCAT') !== false): ?>
|
|
<div class="product-item-label__tag product-item-label__tag--title">
|
|
COSMOCAT
|
|
</div>
|
|
<?php elseif (strpos($product->get_name(), 'КОСМОБАКА') !== false): ?>
|
|
<div class="product-item-label__tag product-item-label__tag--title">
|
|
КОСМОБАКА
|
|
</div>
|
|
<?php elseif (strpos($product->get_name(), 'KOSMOBAKA') !== false): ?>
|
|
<div class="product-item-label__tag product-item-label__tag--title">
|
|
KOSMOBAKA
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php if ($is_sale): ?>
|
|
<div class="product-item-label__tag product-item-label__tag--sale">
|
|
<?php echo esc_html__( 'Sale %', 'woodmart' ) ?>
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
</div>
|
|
|
|
<p class="detail__title">
|
|
<?php the_title() ?>
|
|
</p>
|
|
|
|
<div class="detail__images-phone">
|
|
|
|
<div class="swiper-wrapper">
|
|
<div class="swiper-slide">
|
|
<div class="detail-images-phone__image-block" data-count-img="0">
|
|
<img src="<?php echo wp_get_attachment_url( $post_thumbnail_id ); ?>" alt="">
|
|
</div>
|
|
</div>
|
|
<?php if ($var_gallery):
|
|
|
|
|
|
$i = 0; ?>
|
|
|
|
<?php foreach( $var_gallery as $product_gallery_id ) : ?>
|
|
|
|
<div class="swiper-slide">
|
|
<div class="detail-images-phone__image-block" data-count-img="<?php echo $i ?>">
|
|
<img src="<?php echo $product_gallery_id['src'] ?>" alt="">
|
|
</div>
|
|
</div>
|
|
<?php
|
|
endforeach;
|
|
else:
|
|
?>
|
|
<div class="detail-images-phone__image-block" data-count-img="0">
|
|
<img src="<?php echo wp_get_attachment_url( $post_thumbnail_id ); ?>" alt="">
|
|
</div>
|
|
<?php if( $gallery ) :
|
|
$i = 1; ?>
|
|
<?php foreach( $gallery as $product_gallery_id ) : ?>
|
|
<div class="swiper-slide">
|
|
<div class="detail-images-phone__image-block" data-count-img="<?php echo $i ?>">
|
|
<?php echo wp_get_attachment_image( $product_gallery_id, 'woocommerce_single' ) ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
$i++;
|
|
endforeach; ?>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="swiper-pagination"></div>
|
|
</div>
|
|
|
|
|
|
<?php
|
|
|
|
|
|
if ($product->get_type() == 'variable'):
|
|
?>
|
|
|
|
<?php
|
|
|
|
foreach ($weight_list as $w_product) {
|
|
?>
|
|
|
|
<div class="detail__block-price" data-wg="<?php echo $w_product['attr']; ?>" <?php if (!$w_product['is_chosen']){ echo 'style="display: none;"'; } ?>>
|
|
|
|
|
|
<?php
|
|
if($w_product['sale_price']):
|
|
?>
|
|
<div class="detail-block-price__sale">
|
|
<p class="detail-block-price-sale__text">
|
|
<?= $w_product['regular_price'] ?>
|
|
</p>
|
|
<p class="detail-block-price-sale__perc">
|
|
<?= round(($w_product['regular_price'] - $w_product['sale_price']) / $w_product['regular_price'] * 100) ?>
|
|
</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
<?php
|
|
|
|
elseif($product->get_type() == 'variable-subscription'): ?>
|
|
|
|
|
|
<div class="detail-block-form__item radio-button">
|
|
|
|
<?php
|
|
$choosen_stock = $product->get_stock_quantity();
|
|
$available_variations = $product->get_available_variations();
|
|
$product_id = $available_variations[0]['variation_id']; $i = 0;
|
|
foreach ($available_variations as $key => $value) { $i++;
|
|
$product_variation = new WC_Product_Variation( $value['variation_id'] );
|
|
$variation_price = $product_variation->get_regular_price();
|
|
|
|
$attr = $value['attributes']['attribute_pa_subscription'];
|
|
$attr = get_term_by( 'slug', $attr, 'pa_subscription' );
|
|
|
|
echo '
|
|
<label class="single-subs-period button">
|
|
<input type="radio" data-price="'.$variation_price.'" data-id="'.$value['variation_id'] .'" name="single_subs" '.($i == 1 ? 'checked' : '').'>
|
|
<span>'.$attr->name.'</span>
|
|
</label>
|
|
';
|
|
}
|
|
?>
|
|
</div>
|
|
|
|
|
|
<?php
|
|
else:
|
|
?>
|
|
<?php
|
|
//$subscription_schemes = WCS_ATT_Product_Schemes::get_subscription_schemes( $product );
|
|
//if(!$subscription_schemes): ?>
|
|
|
|
<?php //endif; ?>
|
|
<?php
|
|
endif;
|
|
?>
|
|
<?php
|
|
do_action( 'woocommerce_' . $product->get_type() . '_add_to_cart' );
|
|
?>
|
|
<form action="" class="detail-block__form">
|
|
<?php
|
|
if ($weight_list):
|
|
|
|
?>
|
|
<div class="detail-block-form__item detail-block-form__item--radio radio-button">
|
|
<?php
|
|
|
|
foreach($weight_list as $w):
|
|
|
|
?>
|
|
<a href="<?php echo $w['url'] ?>" class="singular-w-btn button button--white button--red-48-px<?php if ($w['is_chosen']){ echo ' active'; } ?>">
|
|
<?php echo $w['weight'] ?> <?php echo esc_html__( 'kg', 'woodmart' ) ?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
<input type="hidden" name="variation_id" value="<?= $var_id ?>" id="variation_id">
|
|
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
<input type="hidden" name="product_id" value="<?= $product_id; ?>">
|
|
<div class="detail-block-form__item detail-block-form__item--add" <?php if ($choosen_stock == 0){ echo 'style="display:none;"'; } ?>>
|
|
<button type="submit"
|
|
class="button button--gradient button--high detail-block-form__submit">
|
|
<?php echo esc_html__( 'Add to cart', 'woodmart' );?>
|
|
</button>
|
|
</div>
|
|
<div class="detail-block-form__item detail-block-form__item--tn" <?php if ($choosen_stock > 0) { echo 'style="display:none;"'; } ?>>
|
|
<button type="button" class="to-know open-to-know">
|
|
<p><?php echo esc_html__( 'Subscribe to get', 'woodmart' ) ?></p>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
|
|
<div class="detail__toggle">
|
|
<?php
|
|
$excerpt = get_the_excerpt();
|
|
$cont = get_field('contains');
|
|
$rec = get_field('rec');
|
|
$val = get_field('val');
|
|
?>
|
|
<?php
|
|
if ($excerpt):
|
|
?>
|
|
<div class="toggle">
|
|
<p class="toggle__title">
|
|
<?php echo esc_html__( 'DESCRIPTION', 'woodmart' ) ?>
|
|
</p>
|
|
<div class="toggle__block-content">
|
|
<div class="toggle__content">
|
|
<div class="toggle__text">
|
|
<?= $excerpt ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
<?php
|
|
if ($cont):
|
|
?>
|
|
<div class="toggle">
|
|
<p class="toggle__title">
|
|
<?php echo esc_html__( 'COMPOSITION', 'woodmart' ) ?>
|
|
</p>
|
|
<div class="toggle__block-content">
|
|
<div class="toggle__content">
|
|
<div class="toggle__text">
|
|
<?php
|
|
echo $cont;
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
<?php
|
|
if ($rec):
|
|
?>
|
|
<div class="toggle">
|
|
<p class="toggle__title">
|
|
<?php echo esc_html__( 'RECOMENDATIONS', 'woodmart' ) ?>
|
|
</p>
|
|
<div class="toggle__block-content">
|
|
<div class="toggle__content">
|
|
<?php
|
|
echo $rec;
|
|
?>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
<?php
|
|
if ($val):
|
|
?>
|
|
<div class="toggle">
|
|
<p class="toggle__title">
|
|
<?php echo esc_html__( 'NUTRITION', 'woodmart' ) ?>
|
|
</p>
|
|
<div class="toggle__block-content">
|
|
<?php
|
|
echo $val;
|
|
?>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
</div>
|
|
|
|
|
|
<div class="detail__warning">
|
|
<div class="detail-warning__content">
|
|
<p class="detail-warning__title"><?php echo esc_html__( 'Important!', 'woodmart' ) ?></p>
|
|
<p class="detail-warning__text">
|
|
<?php echo esc_html__( 'There should always be a bowl of fresh drinking water near the feeding area.', 'woodmart' ) ?>
|
|
<!-- Рядом с местом кормления всегда должна быть миска со свежей питьевой водой -->
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
$upsell = get_field('similar');
|
|
if ($upsell):
|
|
?>
|
|
<div class="detail__wrapper-catalot">
|
|
<div class="detail__catalot">
|
|
<div class="detail-catalot__header">
|
|
<p class="detail-catalot__title">
|
|
<?php echo esc_html__( 'your pet might like it', 'woodmart' ) ?>
|
|
<!-- вашему питомцу может понравиться -->
|
|
</p>
|
|
|
|
<div class="detail-catalot__control">
|
|
<button class="detail-catalot-control__button prev">
|
|
<img src="<?= get_template_directory_uri();?>/gp-include/assets/core/img/svg/main/arrow-left.svg" alt="">
|
|
</button>
|
|
|
|
<button class="detail-catalot-control__button next">
|
|
<img src="<?= get_template_directory_uri();?>/gp-include/assets/core/img/svg/main/arrow-right.svg" alt="">
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="detail-catalot__content swiper-wrapper">
|
|
<?php
|
|
|
|
foreach ($upsell as $item) {
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
setup_postdata($GLOBALS['post'] = & $item);
|
|
wc_get_template_part('content', 'product')
|
|
?>
|
|
|
|
<?php
|
|
}
|
|
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
endif;
|
|
?>
|
|
</div>
|
|
</main>
|
|
|
|
|
|
<div class="gallery">
|
|
<button class="gallery__close gallery-button">
|
|
<img src="<?= get_template_directory_uri();?>/gp-include/assets/core/img/svg/main/black-x.svg" alt="">
|
|
</button>
|
|
|
|
<div class="gallery__wrapper">
|
|
<div class="gallery__pagination">
|
|
|
|
<?php
|
|
|
|
if ($var_gallery):
|
|
|
|
|
|
$i = 0; ?>
|
|
<?php foreach( $var_gallery as $product_gallery_id ) : ?>
|
|
|
|
<button class="gallery-pagination__item" data-count-img="<?php echo $i ?>">
|
|
<img src="<?php echo $product_gallery_id['src'] ?>" alt="">
|
|
</button>
|
|
<?php
|
|
$i++;
|
|
endforeach; ?>
|
|
<?php else:
|
|
|
|
?>
|
|
<button class="gallery-pagination__item" data-count-img="0">
|
|
<img src="<?php echo wp_get_attachment_url( $post_thumbnail_id ); ?>" alt="">
|
|
</button>
|
|
<?php if( $gallery ) :
|
|
$i = 1; ?>
|
|
<?php foreach( $gallery as $product_gallery_id ) : ?>
|
|
|
|
<button class="gallery-pagination__item" data-count-img="<?php echo $i ?>">
|
|
<?php echo wp_get_attachment_image( $product_gallery_id, 'woocommerce_single' ) ?>
|
|
</button>
|
|
<?php
|
|
$i++;
|
|
endforeach; ?>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
|
|
<div class="gallery__slider swiper">
|
|
<div class="swiper-wrapper">
|
|
|
|
<?php
|
|
|
|
|
|
if ($var_gallery):
|
|
|
|
|
|
$i = 0; ?>
|
|
|
|
<?php foreach( $var_gallery as $product_gallery_id ) : ?>
|
|
<div class="swiper-slide">
|
|
<div class="gallery__block">
|
|
<img src="<?php echo $product_gallery_id['src'] ?>" alt="">
|
|
</div>
|
|
</div>
|
|
<?php
|
|
$i++;
|
|
endforeach;
|
|
else: ?>
|
|
|
|
<div class="swiper-slide">
|
|
<div class="gallery__block">
|
|
<img src="<?php echo wp_get_attachment_url( $post_thumbnail_id ); ?>" alt="">
|
|
</div>
|
|
</div>
|
|
|
|
<?php if( $gallery ) :
|
|
$i = 1; ?>
|
|
<?php foreach( $gallery as $product_gallery_id ) : ?>
|
|
<div class="swiper-slide">
|
|
<div class="gallery__block">
|
|
<?php echo wp_get_attachment_image( $product_gallery_id, 'woocommerce_single' ) ?>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
$i++;
|
|
endforeach; ?>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="swiper-pagination"></div>
|
|
|
|
<div class="swiper-button-prev gallery-button">
|
|
<img src="<?= get_template_directory_uri();?>/gp-include/assets/core/img/svg/main/arrow-left.svg" alt="">
|
|
</div>
|
|
<div class="swiper-button-next gallery-button">
|
|
<img src="<?= get_template_directory_uri();?>/gp-include/assets/core/img/svg/main/arrow-right.svg" alt="">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<?php
|
|
if ($loc == 'en'){
|
|
get_footer('gp_eng');
|
|
}
|
|
else{
|
|
get_footer('gp');
|
|
}
|
|
?>
|
|
|
|
|