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

Fiche Produit pb nommage

parent fb420d39
......@@ -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() {
var varID = jQuery('input[name="variation_id"]').val();
......@@ -31,54 +31,82 @@ jQuery(document).ready(function() {
var name = jQuery(this).attr('name');
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'));
}
if (jQuery(this).is(':checked') && name == 'attribute_pa_format') {
jQuery('.info-format').text(jQuery(this).attr('value'));
jQuery('.info-format-txt').text(jQuery(this).attr('value'));
var format = jQuery('.format-list.selected .format-desc').text();
jQuery('.info-format').text(format);
jQuery('.info-format-txt').text(format);
}
});
jQuery("#search-btn").on('click', function() {
jQuery('article').show();
jQuery('.list-animation section').show();
jQuery('article').removeClass('in_search');
jQuery('article').removeClass('selected');
jQuery('article').removeClass('hidden');
//filtre couleur
var tabcolor = [];
i = 0;
jQuery(".list-color-filter .selected").each(function() {
jQuery("#pa_couleur .selected").each(function() {
tabcolor[i++] = jQuery(this).attr('data-color');
});
//console.log(tabcolor);
jQuery(".product-list article li").each(function() {
var product_color = jQuery(this).attr('data-color');
if (jQuery.inArray(product_color, tabcolor) >= 0) {
jQuery(this).closest('article').addClass('in_search');
}
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({
if (tabcolor.length > 0)
{
jQuery('article:not(.in_search)').hide();
jQuery('.list-animation section').each(function() {
type: 'GET',
url: '',
data: {"pa_couleur": selected_colors,"pa_format":selected_formats},
success: function(data) {
},
error: function() {
if (jQuery(this).find('article.in_search').length == 0) {
jQuery(this).hide();
}
});
jQuery(".product-list article li").each(function() {
var product_color = jQuery(this).attr('data-color');
var product_format = jQuery(this).attr('data-format');
if (jQuery.inArray(product_color, tabcolor) >= 0 || jQuery.inArray(product_format, tabformat) >= 0) {
jQuery(this).closest('article').addClass('in_search');
}
});
*/
});
/*jQuery('.list-animation section').each(function() {
if (jQuery(this).find('article.selected').length == 0) {
jQuery(this).hide();
}
});*/
});
\ No newline at end of file
......@@ -682,3 +682,12 @@ function nap_attribute_by_category($categorie, $attr){
}
add_image_size( 'wordpress-thumbnail', 200, 200, FALSE );
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
......@@ -66,7 +66,6 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
else
$terms = nap_attribute_by_category ($cateID, $value);
if (!empty($terms) && !is_wp_error($terms)):
?>
<div class="bloc-content">
......@@ -76,25 +75,17 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
if ($value == 'pa_couleur'):
$color = get_field('couleurs', 'pa_couleur_' . $term->term_id);
if (isset($color) && strlen($color) > 0):
if(isset($_GET['pa_couleur']) && stristr($_GET['pa_couleur'],$color )) :
$filter_class = 'selected';
else:
$filter_class = '';
endif;
$filter_class = nap_selected_filter($_GET['pa_couleur'],$color);
?>
<li data-color = "<?php echo $color; ?>" class="<?php echo $term->name.' '.$filter_class; ?>"></li>
<?php
endif;
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 )) :
$filter_class = 'selected';
else:
$filter_class = '';
endif;
?>
<li class="<?php echo $filter_class ?>"><?php echo $term; ?></li>
<li class="<?php echo $filter_format.' '.$filter_matiere; ?>"><?php echo $term; ?></li>
<?php
endif;
endforeach;
......
......@@ -254,11 +254,11 @@ do_action('woocommerce_before_add_to_cart_form');
</form>
<div class="product-info row center left border-l">
<div class="info-content">
<?php $format = str_replace('-', ' ', $_GET['attribute_format']);?>
<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">
<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>
</div>
<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