Commit 6204d4ad authored by Nahla Shiri's avatar Nahla Shiri

Fiche Produit pb nommage

parent fb420d39
...@@ -18,7 +18,7 @@ jQuery(document).ready(function() { ...@@ -18,7 +18,7 @@ jQuery(document).ready(function() {
jQuery('li.format-list:first-child input').attr('checked', true);
jQuery(document).on('change', '.color-list input,.format-list input ', function() { jQuery(document).on('change', '.color-list input,.format-list input ', function() {
var varID = jQuery('input[name="variation_id"]').val(); var varID = jQuery('input[name="variation_id"]').val();
...@@ -31,32 +31,65 @@ jQuery(document).ready(function() { ...@@ -31,32 +31,65 @@ jQuery(document).ready(function() {
var name = jQuery(this).attr('name'); var name = jQuery(this).attr('name');
if (jQuery(this).is(':checked') && name == 'attribute_pa_couleur') { if (jQuery(this).is(':checked') && name == 'attribute_pa_couleur') {
jQuery('li.format-list:first-child input').attr('checked', true);
jQuery('.info-color').text(jQuery(this).attr('value')); jQuery('.info-color').text(jQuery(this).attr('value'));
} }
if (jQuery(this).is(':checked') && name == 'attribute_pa_format') { if (jQuery(this).is(':checked') && name == 'attribute_pa_format') {
jQuery('.info-format').text(jQuery(this).attr('value')); var format = jQuery('.format-list.selected .format-desc').text();
jQuery('.info-format-txt').text(jQuery(this).attr('value')); jQuery('.info-format').text(format);
jQuery('.info-format-txt').text(format);
} }
}); });
jQuery("#search-btn").on('click', function() { jQuery("#search-btn").on('click', function() {
jQuery('article').show(); jQuery('article').show();
jQuery('.list-animation section').show(); jQuery('.list-animation section').show();
jQuery('article').removeClass('in_search'); jQuery('article').removeClass('selected');
jQuery('article').removeClass('hidden');
//filtre couleur //filtre couleur
var tabcolor = []; var tabcolor = [];
i = 0; i = 0;
jQuery(".list-color-filter .selected").each(function() { jQuery("#pa_couleur .selected").each(function() {
tabcolor[i++] = jQuery(this).attr('data-color'); tabcolor[i++] = jQuery(this).attr('data-color');
}); });
//console.log(tabcolor);
var tabformat = [];
i = 0;
jQuery("#pa_format .selected").each(function() {
tabformat[i++] = jQuery(this).text();
});
var tabmatiere = [];
i = 0;
jQuery("#pa_matiere .selected").each(function() {
tabmatiere[i++] = jQuery(this).text();
});
var selected_colors = tabcolor.join(',');
var selected_formats = tabformat.join(',');
var selected_matiere = tabmatiere.join(',');
var params = { pa_couleur:selected_colors, pa_format:selected_formats, pa_matiere: selected_matiere};
window.location.href = "?" +jQuery.param(params);
/*history.pushState({}, null, "?" + jQuery.param(params));
jQuery.ajax({
type: 'GET',
url: '',
data: {"pa_couleur": selected_colors,"pa_format":selected_formats},
success: function(data) {
},
error: function() {
}
});
jQuery(".product-list article li").each(function() { jQuery(".product-list article li").each(function() {
var product_color = jQuery(this).attr('data-color'); var product_color = jQuery(this).attr('data-color');
var product_format = jQuery(this).attr('data-format');
if (jQuery.inArray(product_color, tabcolor) >= 0) { if (jQuery.inArray(product_color, tabcolor) >= 0 || jQuery.inArray(product_format, tabformat) >= 0) {
jQuery(this).closest('article').addClass('in_search'); jQuery(this).closest('article').addClass('in_search');
...@@ -64,21 +97,16 @@ jQuery(document).ready(function() { ...@@ -64,21 +97,16 @@ jQuery(document).ready(function() {
}); });
*/
});
if (tabcolor.length > 0) /*jQuery('.list-animation section').each(function() {
{
jQuery('article:not(.in_search)').hide(); if (jQuery(this).find('article.selected').length == 0) {
jQuery('.list-animation section').each(function() {
if (jQuery(this).find('article.in_search').length == 0) {
jQuery(this).hide(); jQuery(this).hide();
} }
}); });*/
}
});
}); });
\ No newline at end of file
...@@ -681,4 +681,13 @@ function nap_attribute_by_category($categorie, $attr){ ...@@ -681,4 +681,13 @@ function nap_attribute_by_category($categorie, $attr){
} }
add_image_size( 'wordpress-thumbnail', 200, 200, FALSE ); add_image_size( 'wordpress-thumbnail', 200, 200, FALSE );
\ No newline at end of file
function nap_selected_filter($search,$attribute){
if(isset($search) && stristr($search,$attribute)) :
$filter_class = 'selected';
else:
$filter_class = '';
endif;
return $filter_class;
}
\ No newline at end of file
...@@ -64,9 +64,8 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of' ...@@ -64,9 +64,8 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
if ($value == 'pa_couleur') if ($value == 'pa_couleur')
$terms = get_terms($value); $terms = get_terms($value);
else else
$terms = nap_attribute_by_category ($cateID, $value); $terms = nap_attribute_by_category ($cateID, $value);
if (!empty($terms) && !is_wp_error($terms)): if (!empty($terms) && !is_wp_error($terms)):
?> ?>
<div class="bloc-content"> <div class="bloc-content">
...@@ -76,25 +75,17 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of' ...@@ -76,25 +75,17 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
if ($value == 'pa_couleur'): if ($value == 'pa_couleur'):
$color = get_field('couleurs', 'pa_couleur_' . $term->term_id); $color = get_field('couleurs', 'pa_couleur_' . $term->term_id);
if (isset($color) && strlen($color) > 0): if (isset($color) && strlen($color) > 0):
if(isset($_GET['pa_couleur']) && stristr($_GET['pa_couleur'],$color )) : $filter_class = nap_selected_filter($_GET['pa_couleur'],$color);
$filter_class = 'selected';
else:
$filter_class = '';
endif;
?> ?>
<li data-color = "<?php echo $color; ?>" class="<?php echo $term->name.' '.$filter_class; ?>"></li> <li data-color = "<?php echo $color; ?>" class="<?php echo $term->name.' '.$filter_class; ?>"></li>
<?php <?php
endif; endif;
else : else :
$filter_format = nap_selected_filter($_GET['pa_format'],$term);
$filter_matiere = nap_selected_filter($_GET['pa_matiere'],$term);
?> ?>
<?php
if(isset($_GET['pa_format']) && stristr($_GET['pa_format'],$term )) : <li class="<?php echo $filter_format.' '.$filter_matiere; ?>"><?php echo $term; ?></li>
$filter_class = 'selected';
else:
$filter_class = '';
endif;
?>
<li class="<?php echo $filter_class ?>"><?php echo $term; ?></li>
<?php <?php
endif; endif;
endforeach; endforeach;
......
...@@ -254,11 +254,11 @@ do_action('woocommerce_before_add_to_cart_form'); ...@@ -254,11 +254,11 @@ do_action('woocommerce_before_add_to_cart_form');
</form> </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">
<?php $format = str_replace('-', ' ', $_GET['attribute_format']);?>
<h2 class = "crete font-small" ><?php echo $sub_cat[0]->name; ?></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 $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 $format; ?></p>
<p class="pq"><?php echo nap_variable_meta($current_variationID, 'variation_description'); ?></p> <p class="pq"><?php echo nap_variable_meta($current_variationID, 'variation_description'); ?></p>
</div> </div>
<div class="price"> <div class="price">
......
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