Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
NAP-wordpress
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marwa Sfari
NAP-wordpress
Commits
8dd0fa18
Commit
8dd0fa18
authored
Aug 22, 2017
by
Nahla Shiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
corretion filter
parent
540de525
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
27 deletions
+8
-27
functions.php
wp-content/themes/nap/functions.php
+5
-2
archive-product.php
wp-content/themes/nap/woocommerce/archive-product.php
+3
-25
No files found.
wp-content/themes/nap/functions.php
View file @
8dd0fa18
...
@@ -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
wp-content/themes/nap/woocommerce/archive-product.php
View file @
8dd0fa18
<?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
))
:
?>
?>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment