Commit 8e352074 authored by Nahla Shiri's avatar Nahla Shiri

produits associes

parent 322aa004
...@@ -74,18 +74,18 @@ jQuery(document).ready(function() { ...@@ -74,18 +74,18 @@ jQuery(document).ready(function() {
jQuery("#pa_matiere .selected").each(function() { jQuery("#pa_matiere .selected").each(function() {
tabmatiere[i++] = jQuery(this).text(); tabmatiere[i++] = jQuery(this).text();
}); });
var tabunivers = []; var tabunivers = [];
i = 0; i = 0;
jQuery("#pa_univers .selected").each(function() { jQuery("#pa_univers .selected").each(function() {
tabunivers[i++] = jQuery(this).text(); tabunivers[i++] = jQuery(this).text();
}); });
var selected_colors = tabcolor.join(','); var selected_colors = tabcolor.join(',');
var selected_formats = tabformat.join(','); var selected_formats = tabformat.join(',');
var selected_matiere = tabmatiere.join(','); var selected_matiere = tabmatiere.join(',');
var selected_univers = tabunivers.join(','); var selected_univers = tabunivers.join(',');
var params = {pa_couleur: selected_colors, pa_format: selected_formats, pa_matiere: selected_matiere, pa_univers:selected_univers}; var params = {pa_couleur: selected_colors, pa_format: selected_formats, pa_matiere: selected_matiere, pa_univers: selected_univers};
window.location.href = "?" + jQuery.param(params); window.location.href = "?" + jQuery.param(params);
/*history.pushState({}, null, "?" + jQuery.param(params)); /*history.pushState({}, null, "?" + jQuery.param(params));
...@@ -116,26 +116,28 @@ jQuery(document).ready(function() { ...@@ -116,26 +116,28 @@ jQuery(document).ready(function() {
}); });
jQuery(window).on('load',function() {
jQuery('.filter-bloc ').each(function() {
jQuery('.filter-bloc ').each(function() { if (jQuery(this).find('.bloc-content').length == 0) {
if (jQuery(this).find('.bloc-content').length == 0) { jQuery(this).hide();
}
});
jQuery(this).hide();
}
});
jQuery('.list-animation section').each(function() { jQuery('.list-animation section').each(function() {
if (jQuery(this).find("article").length) { if (jQuery(this).find("article").length) {
console.log('article found'); // console.log('article found');
} }
else { else {
jQuery(this).hide(); jQuery(this).hide();
} }
}) });
});
......
...@@ -754,3 +754,40 @@ function nap_change_filter_post() { ...@@ -754,3 +754,40 @@ function nap_change_filter_post() {
} }
} }
} }
function nap_show_associated_products() {
$associated_products = '';
global $product;
$upsells = wc_products_array_orderby( array_filter( array_map( 'wc_get_product', $product->get_upsell_ids() ), 'wc_products_array_filter_visible' ), 'rand', 'desc' );
$associated_products .= '<div class="suggest-header">
<h2>Produits associés</h2>
<span class="close-btn"></span>
</div>
<div class="product-list-content">';
foreach ( $upsells as $upsell ) :
$img = '';
if(has_post_thumbnail($upsell->get_id()))
$img = get_the_post_thumbnail($upsell->get_id(), 'medium');
else {
$product = new WC_Product_Variable( $upsell->get_id() );
$variations = $product->get_available_variations();
if(isset($variations[0]))
$img = get_the_post_thumbnail($variations[0]['variation_id'], 'medium');
}
$associated_products .= '<article class = "row full-width">
<a href="#"></a>
<figure>
'.$img.'
</figure>
<h3 class = "font-small" >'. $upsell->name .'</h3>
</article>';
endforeach;
$associated_products .= '</div>';
return $associated_products;
}
\ No newline at end of file
...@@ -72,7 +72,9 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of' ...@@ -72,7 +72,9 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
<ul <?php if ($value == 'pa_couleur') echo 'class = "list-color-filter clearfix"'; ?> id="<?php echo $value; ?>"> <ul <?php if ($value == 'pa_couleur') echo 'class = "list-color-filter clearfix"'; ?> id="<?php echo $value; ?>">
<?php <?php
$colors = array(); $colors = array();
foreach ($terms as $term) :
foreach ( $terms as $term) :
if ($value == 'pa_couleur'): if ($value == 'pa_couleur'):
$colors[$term->name] = get_field('couleurs', 'pa_couleur_' . $term->term_id); $colors[$term->name] = get_field('couleurs', 'pa_couleur_' . $term->term_id);
...@@ -80,8 +82,15 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of' ...@@ -80,8 +82,15 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
$filter_format = nap_selected_filter($_GET['pa_format'], $term); $filter_format = nap_selected_filter($_GET['pa_format'], $term);
$filter_matiere = nap_selected_filter($_GET['pa_matiere'], $term); $filter_matiere = nap_selected_filter($_GET['pa_matiere'], $term);
$filter_univers = nap_selected_filter($_GET['pa_univers'], $term); $filter_univers = nap_selected_filter($_GET['pa_univers'], $term);
if($value == 'pa_univers')
{ $unv = get_term_by('name', $term, 'pa_univers');
$termID = $term->term_id;
$date_deb = get_field('uv_date_debut', 'pa_univers_' . $unv->term_id);
$date_fin = get_field('uv_date_fin', 'pa_univers_' . $unv->term_id);
}
?> ?>
<li class="<?php echo $filter_format . ' ' . $filter_matiere .' '.$filter_univers ; ?>"><?php echo $term; ?></li> <li class="<?php echo $filter_format . ' ' . $filter_matiere .' '.$filter_univers ; ?>"><?php echo $term; ?></li>
<?php <?php
endif; endif;
...@@ -188,6 +197,7 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of' ...@@ -188,6 +197,7 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
$list_att['pa_univers'] = $value->name; $list_att['pa_univers'] = $value->name;
} }
} }
nap_filter_attribute($id, $args, $options, $list_att, $_GET); nap_filter_attribute($id, $args, $options, $list_att, $_GET);
} else { } else {
echo nap_get_item($id, $args, $current_page, $options); echo nap_get_item($id, $args, $current_page, $options);
......
...@@ -157,30 +157,20 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -157,30 +157,20 @@ do_action('woocommerce_before_add_to_cart_form');
<a class="btn pink-btn rounded download-btn download_file">Télécharger la fiche technique </a> <a class="btn pink-btn rounded download-btn download_file">Télécharger la fiche technique </a>
<a href="<?php echo get_permalink(43); ?>?product_id=<?php echo $product->get_id() ?>&" class="hidden download_file_link" id="<?php echo $current_variationID ?>"></a> <a href="<?php echo get_permalink(43); ?>?product_id=<?php echo $product->get_id() ?>&" class="hidden download_file_link" id="<?php echo $current_variationID ?>"></a>
</div> </div>
<?php if(count($product->get_upsell_ids())):
?>
<div class="font-small circle-btn add-icon show-product"><span class= "abs-center">Produits associées</span></div> <div class="font-small circle-btn add-icon show-product"><span class= "abs-center">Produits associées</span></div>
<?php
endif;
?>
</div> </div>
</div> </div>
<div class="product-list transition border-l fixed"> <div class="product-list transition border-l fixed">
<div class="suggest-header">
<h2>Produits associés</h2> <?php
<span class="close-btn"></span> echo nap_show_associated_products();
</div> ?>
<div class="product-list-content">
<article class = "row full-width">
<a href="#"></a>
<figure>
<img src="http://nap.mano.fr/wp-content/uploads/2017/07/505714-papier-toilette-jumbo-500x375.jpg" alt="" title="">
</figure>
<h3 class = "font-small" >Bobines papier toilette</h3>
</article>
<article class = "row full-width">
<a href="#"></a>
<figure>
<img src="http://nap.mano.fr/wp-content/uploads/2017/07/450108-flexibles-noirs-21cm-315x500.jpg" alt="" title="">
</figure>
<h3 class = "font-small" >Pailles</h3>
</article>
</div>
</div> </div>
<div class="display--only-mobile"><span class = "chevron bottom blue-bg down-btn show-product-mobile"></span></div> <div class="display--only-mobile"><span class = "chevron bottom blue-bg down-btn show-product-mobile"></span></div>
</div> </div>
...@@ -289,32 +289,18 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -289,32 +289,18 @@ do_action('woocommerce_before_add_to_cart_form');
<a class="btn pink-btn rounded download-btn download_file">Télécharger la fiche technique </a> <a class="btn pink-btn rounded download-btn download_file">Télécharger la fiche technique </a>
<a href="<?php echo get_permalink(43); ?>?product_id=<?php echo $product->get_id()?>&" class="hidden download_file_link" id="<?php echo $current_variationID ?>"></a> <a href="<?php echo get_permalink(43); ?>?product_id=<?php echo $product->get_id()?>&" class="hidden download_file_link" id="<?php echo $current_variationID ?>"></a>
</div> </div>
<?php if(count($product->get_upsell_ids())):
?>
<div class="font-small circle-btn add-icon show-product"><span class= "abs-center">Produits associées</span></div> <div class="font-small circle-btn add-icon show-product"><span class= "abs-center">Produits associées</span></div>
</div> </div>
<?php
endif;
?>
</div> </div>
<div class="product-list transition border-l fixed"> <div class="product-list transition border-l fixed">
<div class="suggest-header"> <?php
<h2>Produits associés</h2> echo nap_show_associated_products();
<span class="close-btn"></span> ?>
</div>
<div class="product-list-content">
<article class = "row full-width">
<a href="#"></a>
<figure>
<img src="http://nap.mano.fr/wp-content/uploads/2017/07/505714-papier-toilette-jumbo-500x375.jpg" alt="" title="">
</figure>
<h3 class = "font-small" >Bobines papier toilette</h3>
</article>
<article class = "row full-width">
<a href="#"></a>
<figure>
<img src="http://nap.mano.fr/wp-content/uploads/2017/07/450108-flexibles-noirs-21cm-315x500.jpg" alt="" title="">
</figure>
<h3 class = "font-small" >Pailles</h3>
</article>
</div>
</div> </div>
<div class="display--only-mobile"><span class = "chevron bottom blue-bg down-btn show-product-mobile"></span></div> <div class="display--only-mobile"><span class = "chevron bottom blue-bg down-btn show-product-mobile"></span></div>
</div> </div>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
exit; exit;
} }
/*
if ( $upsells ) : ?> if ( $upsells ) : ?>
<section class="up-sells upsells products"> <section class="up-sells upsells products">
...@@ -46,3 +46,4 @@ if ( $upsells ) : ?> ...@@ -46,3 +46,4 @@ if ( $upsells ) : ?>
<?php endif; <?php endif;
wp_reset_postdata(); wp_reset_postdata();
*/
\ No newline at end of file
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