Commit 7cb2e887 authored by Nahla Shiri's avatar Nahla Shiri

function.php

parent 344636f1
......@@ -57,7 +57,6 @@ jQuery(document).ready(function() {
jQuery('article').removeClass('hidden');
//filtre couleur
var tabcolor = [];
i = 0;
jQuery("#pa_couleur .selected").each(function() {
......@@ -75,10 +74,18 @@ jQuery(document).ready(function() {
jQuery("#pa_matiere .selected").each(function() {
tabmatiere[i++] = jQuery(this).text();
});
var tabunivers = [];
i = 0;
jQuery("#pa_univers .selected").each(function() {
tabunivers[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};
var selected_univers = tabunivers.join(',');
var params = {pa_couleur: selected_colors, pa_format: selected_formats, pa_matiere: selected_matiere, pa_univers:selected_univers};
window.location.href = "?" + jQuery.param(params);
/*history.pushState({}, null, "?" + jQuery.param(params));
......
......@@ -726,3 +726,20 @@ function nap_trash_fiche_technique($post_id) {
$wpdb->delete($table, array('meta_key' => 'fiche_simple_auto', 'meta_value' => $post->post_title));
$wpdb->delete($table, array('meta_key' => 'fiche_var_auto', 'meta_value' => $post->post_title));
}
add_action( 'pre_get_posts', 'nap_change_filter_post' );
function nap_change_filter_post() {
global $wp_query;
if(is_admin()) {
if(!empty($wp_query->query_vars['product_cat'])) {
setcookie("product_cat", $wp_query->query_vars['product_cat']);
}
if(!isset($_GET['product_cat']) && ($_GET['post_type'] == 'product')) {
$wp_query->query_vars['product_cat'] = $_COOKIE['product_cat'];
}
elseif(isset($_GET['product_cat']) && empty($_GET['product_cat'])) {
setcookie("product_cat", $wp_query->query_vars['product_cat']);
}
}
}
......@@ -76,18 +76,13 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
if ($value == 'pa_couleur'):
$colors[$term->name] = get_field('couleurs', 'pa_couleur_' . $term->term_id);
/* if (isset($color) && strlen($color) > 0):
$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);
$filter_univers = nap_selected_filter($_GET['pa_univers'], $term);
?>
<li class="<?php echo $filter_format . ' ' . $filter_matiere; ?>"><?php echo $term; ?></li>
<li class="<?php echo $filter_format . ' ' . $filter_matiere .' '.$filter_univers ; ?>"><?php echo $term; ?></li>
<?php
endif;
endforeach;
......@@ -120,7 +115,7 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
</div>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<?php
foreach ($child_category as $key => $value) :
?>
......@@ -130,12 +125,12 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
</div>
</div>
<?php
endforeach;
?>
endforeach;
?>
</div>
<div class="right-panel right">
<div class="panel panel-content list-animation">
<?php if ($_GET['pa_couleur'] != '' || $_GET['pa_format'] != '' || $_GET['pa_matiere'] != ''): ?>
<?php if ($_GET['pa_couleur'] != '' || $_GET['pa_format'] != '' || $_GET['pa_matiere'] != ''): ?>
<span class="search_result">Résultat de votre recherche :</span>
<?php endif; ?>
......@@ -167,10 +162,6 @@ endforeach;
'order' => 'asc',
'post_parent' => $id
);
?>
<?php
/* * ************* */
$attribute_value['pa_couleur'] = get_the_terms($id, 'pa_couleur');
$attribute_value['pa_format'] = get_the_terms($id, 'pa_format');
$attribute_value['pa_matiere'] = get_the_terms($id, 'pa_matiere');
......@@ -211,4 +202,4 @@ endforeach;
</div>
</div>
</div>
<?php get_footer(); ?>
\ No newline at end of file
<?php get_footer(); ?>
\ 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