Commit 470f856a authored by Nahla Shiri's avatar Nahla Shiri

Ajouter des images ambiance dans une fiche produit

parent 733aa4a6
...@@ -471,7 +471,7 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul ...@@ -471,7 +471,7 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
} }
else else
{ {
$nap_article.='<li data-link = "' . get_permalink($post_ID). '" data-image = "' . nap_image_resize(get_the_post_thumbnail_url($value->ID),'200') . '"></li> '; $nap_article.='<li data-link = "' . get_permalink($post_ID). '" data-image = "' . nap_image_resize(get_the_post_thumbnail_url($value->ID),'200') . '" data-color = "' . get_post_thumbnail_id( $post_ID ) . '" data-format = ""></li> ';
} }
$nap_article.='</ul>'; $nap_article.='</ul>';
endif; endif;
......
<?php <?php
//print_r($_GET); // A factoriser avec variable.php
/**
* Variable product add to cart
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/variable.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 3.0.0
*/
if (!defined('ABSPATH')) { if (!defined('ABSPATH')) {
exit; exit;
} }
global $product; global $product;
$ambiance_product = $product->get_gallery_attachment_ids();
$id = get_the_ID(); $id = get_the_ID();
$parent_cat = wp_get_post_terms($product->get_id(), 'product_cat', array( 'parent' => 0,'fields' => 'ids' )); $parent_cat = wp_get_post_terms($product->get_id(), 'product_cat', array('parent' => 0, 'fields' => 'ids'));
$sub_cat = wp_get_post_terms($product->get_id(), 'product_cat', array( 'parent' =>$parent_cat[0],'fields' => 'names' )); $sub_cat = wp_get_post_terms($product->get_id(), 'product_cat', array('parent' => $parent_cat[0], 'fields' => 'all'));
//Get Back URL
$ext_ref = externe_referrer(); $ext_ref = externe_referrer();
$class_back = ""; $class_back = "";
if($ext_ref) { if ($ext_ref) {
$category_link = get_category_link($parent_cat[0]); $category_link = get_category_link($parent_cat[0]);
$class_back = "ext-link"; $class_back = "ext-link";
}else{ } else {
$category_link ="#"; $category_link = "#";
} }
do_action('woocommerce_before_add_to_cart_form'); do_action('woocommerce_before_add_to_cart_form');
?> ?>
<ul class="hidden">
<li class="color-list selected " data-color="<?php echo get_post_thumbnail_id($ID) ?>"></li>
</ul>
<div id="product" class="clearfix"> <div id="product" class="clearfix">
<div class="product-images row animated"> <div class="product-images row animated">
<div class = "btn-wrapper row close-panel <?php echo $class_back ?>"> <div class = "btn-wrapper row close-panel <?php echo $class_back ?>">
...@@ -43,7 +31,7 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -43,7 +31,7 @@ do_action('woocommerce_before_add_to_cart_form');
</div> </div>
<div class="product-slides row"> <div class="product-slides row">
<div class="product-header"> <div class="product-header">
<h2 class="crete -italic font-small"><?php echo $sub_cat[0] ?></h2> <h2 class="crete -italic font-small"><?php echo $sub_cat[0]->name ?></h2>
<h3 class="crete"><?php the_title(); ?></h3> <h3 class="crete"><?php the_title(); ?></h3>
</div> </div>
<div class="slides-wrapper center"> <div class="slides-wrapper center">
...@@ -58,7 +46,7 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -58,7 +46,7 @@ do_action('woocommerce_before_add_to_cart_form');
<div id="slides"> <div id="slides">
<?php <?php
?> ?>
<div style="background-image:url('<?php echo get_the_post_thumbnail_url($ID, 'medium') ?>')" class="image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle" data-slick-index = "1"> <div style="background-image:url('<?php echo get_the_post_thumbnail_url($ID, 'medium') ?>')" class="image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle" data-color = "<?php echo get_post_thumbnail_id($ID) ?>" data-slick-index = "1">
<a href="<?php echo get_the_post_thumbnail_url($ID, 'full') ?>"> <a href="<?php echo get_the_post_thumbnail_url($ID, 'full') ?>">
<!--<img src="<?php echo get_the_post_thumbnail_url($ID, 'medium') ?>" alt="" />--> <!--<img src="<?php echo get_the_post_thumbnail_url($ID, 'medium') ?>" alt="" />-->
</a> </a>
...@@ -66,24 +54,27 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -66,24 +54,27 @@ do_action('woocommerce_before_add_to_cart_form');
<?php <?php
/* if (get_field('images_ambiance', 'product_cat_' . $subcat_iD)): if (get_field('images_ambiance', 'product_cat_' . $sub_cat[0]->term_id)):
if (!empty($ambiance_product)) {
$ambiance = $ambiance_product;
} else {
$ambiance = array(); $ambiance = array();
while (has_sub_field('images_ambiance', 'product_cat_' . $subcat_iD)) : }
while (has_sub_field('images_ambiance', 'product_cat_' . $sub_cat[0]->term_id)) :
$image_amb = get_sub_field('img_ab'); $image_amb = get_sub_field('img_ab');
$ambiance [] = $image_amb; $ambiance [] = $image_amb;
$attachment = wp_get_attachment_image_src($image_amb, 'medium');
$hd = wp_get_attachment_image_src($image_amb, 'full');
?>
<div style="background-image:url('<?php echo $attachment[0]; ?>')" class="image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle" data-slick-index = "1">
<a href="<?php echo $hd[0]; ?>">
<!--<img src="<?php echo $attachment[0]; ?>" alt="" />-->
</a>
</div>
<?php
endwhile; endwhile;
endif; */ endif;
foreach ($ambiance as $key => $value) :
$attachment = wp_get_attachment_image_src($value, 'medium');
$hd = wp_get_attachment_image_src($value, 'full');
?> ?>
<div style="background-image:url('<?php echo $attachment[0]; ?>')" class="image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle" data-color = "<?php echo $value; ?>" data-slick-index = "1">
<a href="<?php echo $hd[0]; ?>"> </a>
</div>
<?php endforeach; ?>
</div> </div>
</div> </div>
...@@ -92,7 +83,7 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -92,7 +83,7 @@ do_action('woocommerce_before_add_to_cart_form');
<span class="close-btn"></span> <span class="close-btn"></span>
<article class = "row" data-color = ""> <article class = "row" data-color = "<?php echo get_post_thumbnail_id($ID) ?>">
<a href="<?php echo get_the_post_thumbnail_url($ID, 'full') ?>"></a> <a href="<?php echo get_the_post_thumbnail_url($ID, 'full') ?>"></a>
<figure> <figure>
<img src="<?php echo get_the_post_thumbnail_url($ID, 'medium') ?>" alt="" title=""> <img src="<?php echo get_the_post_thumbnail_url($ID, 'medium') ?>" alt="" title="">
...@@ -105,7 +96,7 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -105,7 +96,7 @@ do_action('woocommerce_before_add_to_cart_form');
$hd = wp_get_attachment_image_src($value, 'full'); $hd = wp_get_attachment_image_src($value, 'full');
?> ?>
<article class = "row" data-color = "red"> <article class = "row" data-color = "<?php echo $value; ?>">
<a class = "download-btn" href="<?php echo $hd[0]; ?>" download></a> <a class = "download-btn" href="<?php echo $hd[0]; ?>" download></a>
<figure> <figure>
<img src="<?php echo $attachment[0]; ?>" alt="" title=""> <img src="<?php echo $attachment[0]; ?>" alt="" title="">
...@@ -129,13 +120,13 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -129,13 +120,13 @@ do_action('woocommerce_before_add_to_cart_form');
<div class="product-info row center right border-l"> <div class="product-info row center right border-l">
<div class="info-content"> <div class="info-content">
<?php $formats = explode(',', nap_variation_format($id)); ?> <?php $formats = explode(',', nap_variation_format($id)); ?>
<h2 class = "crete font-small" ><?php echo $sub_cat[0] ?></h2> <h2 class = "crete font-small" ><?php echo $sub_cat[0]->name ?></h2>
<h3 class = "crete font-small info-attr" ><span class="info-format"><?php echo $formats[0]; ?></span> <span class="info-color"><?php echo$_GET['attribute_couleur'] ?></span></h3> <h3 class = "crete font-small info-attr" ><span class="info-format"><?php echo $formats[0]; ?></span> <span class="info-color"><?php echo$_GET['attribute_couleur'] ?></span></h3>
<div class="details font-small"> <div class="details font-small">
<p class="info-format-txt"> <p class="info-format-txt">
<?php echo $formats[0]; ?> <?php echo $formats[0]; ?>
</p> </p>
<p class="pq"><?php echo do_shortcode(get_the_excerpt());?></p> <p class="pq"><?php echo do_shortcode(get_the_excerpt()); ?></p>
</div> </div>
<div class="price"> <div class="price">
<span class="crete"><?php echo $price = get_post_meta(get_the_ID(), '_regular_price', true); ?> € ht</span> <span class="crete"><?php echo $price = get_post_meta(get_the_ID(), '_regular_price', true); ?> € ht</span>
...@@ -187,8 +178,6 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -187,8 +178,6 @@ do_action('woocommerce_before_add_to_cart_form');
</figure> </figure>
<h3 class = "font-small" >Pailles</h3> <h3 class = "font-small" >Pailles</h3>
</article> </article>
</div> </div>
</div> </div>
</div> </div>
<?php <?php
//print_r($_GET);
/** /**
* Variable product add to cart * Variable product add to cart
* *
...@@ -21,11 +20,12 @@ if (!defined('ABSPATH')) { ...@@ -21,11 +20,12 @@ if (!defined('ABSPATH')) {
} }
global $product; global $product;
$ambiance_product = $product->get_gallery_attachment_ids();
$attribute_keys = array_keys($attributes); $attribute_keys = array_keys($attributes);
$parent_cat = wp_get_post_terms($product->get_id(), 'product_cat', array( 'parent' => 0,'fields' => 'ids' )); $parent_cat = wp_get_post_terms($product->get_id(), 'product_cat', array( 'parent' => 0,'fields' => 'ids' ));
$sub_cat = wp_get_post_terms($product->get_id(), 'product_cat', array( 'parent' =>$parent_cat[0],'fields' => 'names' )); $sub_cat = wp_get_post_terms($product->get_id(), 'product_cat', array( 'parent' =>$parent_cat[0],'fields' => 'all' ));
$current_variationID = $_GET['variation_id']; $current_variationID = $_GET['variation_id'];
$ext_ref = externe_referrer(); $ext_ref = externe_referrer();
$class_back = ""; $class_back = "";
...@@ -84,7 +84,7 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -84,7 +84,7 @@ do_action('woocommerce_before_add_to_cart_form');
</div> </div>
<div class="product-slides row"> <div class="product-slides row">
<div class="product-header"> <div class="product-header">
<h2 class="crete -italic font-small"><?php echo $sub_cat[0]; ?></h2> <h2 class="crete -italic font-small"><?php echo $sub_cat[0]->name; ?></h2>
<h3 class="crete"><?php the_title();?></h3> <h3 class="crete"><?php the_title();?></h3>
</div> </div>
<div class="slides-wrapper center"> <div class="slides-wrapper center">
...@@ -113,24 +113,26 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -113,24 +113,26 @@ do_action('woocommerce_before_add_to_cart_form');
?> ?>
<?php <?php
if (get_field('images_ambiance', 'product_cat_' . $subcat_iD)): if (get_field('images_ambiance', 'product_cat_' . $sub_cat[0]->term_id)):
if (!empty($ambiance_product)) {
$ambiance = $ambiance_product;
} else {
$ambiance = array(); $ambiance = array();
while (has_sub_field('images_ambiance', 'product_cat_' . $subcat_iD)) : }
while (has_sub_field('images_ambiance', 'product_cat_' . $sub_cat[0]->term_id)) :
$image_amb = get_sub_field('img_ab'); $image_amb = get_sub_field('img_ab');
$ambiance [] = $image_amb; $ambiance [] = $image_amb;
$attachment = wp_get_attachment_image_src($image_amb, 'medium');
$hd = wp_get_attachment_image_src($image_amb, 'full');
?>
<div style="background-image:url('<?php echo $attachment[0]; ?>')" class="image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle" data-color = "<?php echo $color ?>" data-slick-index = "1">
<a href="<?php echo $hd[0]; ?>">
<!--<img src="<?php echo $attachment[0]; ?>" alt="" />-->
</a>
</div>
<?php
endwhile; endwhile;
endif; endif;
foreach ($ambiance as $key => $value) :
$attachment = wp_get_attachment_image_src($value, 'medium');
$hd = wp_get_attachment_image_src($value, 'full');
?> ?>
<div style="background-image:url('<?php echo $attachment[0]; ?>')" class="image element-slider easyzoom easyzoom--overlay easyzoom--with-toggle" data-color = "<?php echo $value; ?>" data-slick-index = "1">
<a href="<?php echo $hd[0]; ?>"> </a>
</div>
<?php endforeach; ?>
</div> </div>
</div> </div>
...@@ -153,7 +155,7 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -153,7 +155,7 @@ do_action('woocommerce_before_add_to_cart_form');
$hd = wp_get_attachment_image_src($value, 'full'); $hd = wp_get_attachment_image_src($value, 'full');
?> ?>
<article class = "row" data-color = "red"> <article class = "row" data-color = "<?php echo $value; ?>">
<a class = "download-btn" href="<?php echo $hd[0]; ?>" download></a> <a class = "download-btn" href="<?php echo $hd[0]; ?>" download></a>
<figure> <figure>
<img src="<?php echo $attachment[0]; ?>" alt="" title=""> <img src="<?php echo $attachment[0]; ?>" alt="" title="">
...@@ -249,7 +251,7 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -249,7 +251,7 @@ do_action('woocommerce_before_add_to_cart_form');
<div class="product-info row center left border-l"> <div class="product-info row center left border-l">
<div class="info-content"> <div class="info-content">
<h2 class = "crete font-small" ><?php echo $sub_cat[0]; ?></h2> <h2 class = "crete font-small" ><?php echo $sub_cat[0]->name; ?></h2>
<h3 class = "crete font-small info-attr" ><span class="info-format"><?php echo $_GET['attribute_format']?></span> <span class="info-color"><?php echo$_GET['attribute_couleur'] ?></span></h3> <h3 class = "crete font-small info-attr" ><span class="info-format"><?php echo $_GET['attribute_format']?></span> <span class="info-color"><?php echo$_GET['attribute_couleur'] ?></span></h3>
<div class="details font-small"> <div class="details font-small">
<p class="info-format-txt"><?php echo $_GET['attribute_format']?></p> <p class="info-format-txt"><?php echo $_GET['attribute_format']?></p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment