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){
$products = get_posts($args);
$attribute=array();
foreach ($products as $key => $value) {
$attribute[] = array_shift(woocommerce_get_product_terms($value->ID, $attr, 'names'));
$list_attr= woocommerce_get_product_terms($value->ID, $attr, 'names');
foreach($list_attr as $key => $value){
$attribute[] = $value;
}
}
return array_unique($attribute);
}
add_image_size( 'wordpress-thumbnail', 200, 200, FALSE );
\ No newline at end of file
<?php
print_r($_GET);
//print_r($_GET);
/**
* The Template for displaying product archives, including the main shop page which is a post type archive
*
......@@ -23,32 +23,10 @@ $current_page = 'catalogue';
get_header();
$product;
$cate = get_queried_object();
print '******CATID Nahla'.$cateID = $cate->term_id;
$cateID = $cate->term_id;
//SubCats
$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; ?>">
......@@ -87,7 +65,7 @@ if(is_product_category()){
$terms = get_terms($value);
else
$terms = nap_attribute_by_category ($cateID, $value);
//print_r($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