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

corretion filter

parent 540de525
...@@ -658,10 +658,13 @@ function nap_attribute_by_category($categorie, $attr){ ...@@ -658,10 +658,13 @@ function nap_attribute_by_category($categorie, $attr){
$products = get_posts($args); $products = get_posts($args);
$attribute=array(); $attribute=array();
foreach ($products as $key => $value) { foreach ($products as $key => $value) {
$list_attr= woocommerce_get_product_terms($value->ID, $attr, 'names');
$attribute[] = array_shift(woocommerce_get_product_terms($value->ID, $attr, 'names')); foreach($list_attr as $key => $value){
$attribute[] = $value;
}
} }
return array_unique($attribute); return array_unique($attribute);
} }
add_image_size( 'wordpress-thumbnail', 200, 200, FALSE );
\ No newline at end of file
<?php <?php
print_r($_GET); //print_r($_GET);
/** /**
* The Template for displaying product archives, including the main shop page which is a post type archive * The Template for displaying product archives, including the main shop page which is a post type archive
* *
...@@ -23,32 +23,10 @@ $current_page = 'catalogue'; ...@@ -23,32 +23,10 @@ $current_page = 'catalogue';
get_header(); get_header();
$product; $product;
$cate = get_queried_object(); $cate = get_queried_object();
print '******CATID Nahla'.$cateID = $cate->term_id; $cateID = $cate->term_id;
//SubCats //SubCats
$child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of' => the_category_ID(), 'exclude' => $cateID, 'orderby' => 'title', 'order' => 'ASC')); $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of' => the_category_ID(), 'exclude' => $cateID, 'orderby' => 'title', 'order' => 'ASC'));
$products =nap_attribute_by_category($cateID, 'pa_format');
print_r($products);
if(is_product_category()){
global $product;
// the array of attributes names
$attribute_names = array('pa_format','pa_matiere');
foreach( $attribute_names as $key => $attribute_name ) {
// Getting the value of an attribute
$attribute_value = array_shift(wc_get_product_terms( $product->id, $attribute_name));
// Displays only if attribute exist for the product
if(!empty($attribute_value) || $attribute_value == '0' ){
echo print"*********".$attribute_value;
// Separating each number by a " / "
if($key < 3) echo ' / ';
}
}
}
?> ?>
<div class="container clearfix" id="catalogue" data-page = "<?php echo $cateID; ?>"> <div class="container clearfix" id="catalogue" data-page = "<?php echo $cateID; ?>">
...@@ -87,7 +65,7 @@ if(is_product_category()){ ...@@ -87,7 +65,7 @@ if(is_product_category()){
$terms = get_terms($value); $terms = get_terms($value);
else else
$terms = nap_attribute_by_category ($cateID, $value); $terms = nap_attribute_by_category ($cateID, $value);
//print_r($terms);
if (!empty($terms) && !is_wp_error($terms)): if (!empty($terms) && !is_wp_error($terms)):
?> ?>
......
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