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
6c46b2a2
Commit
6c46b2a2
authored
Aug 23, 2017
by
Nahla Shiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ne pas afficher des critères vide
parent
6204d4ad
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
290 additions
and
244 deletions
+290
-244
nap.js
wp-content/themes/nap/assets/js/nap.js
+18
-4
functions.php
wp-content/themes/nap/functions.php
+267
-240
archive-product.php
wp-content/themes/nap/woocommerce/archive-product.php
+5
-0
No files found.
wp-content/themes/nap/assets/js/nap.js
View file @
6c46b2a2
...
...
@@ -100,13 +100,27 @@ jQuery(document).ready(function() {
*/
});
/*
jQuery('.list-animation section').each(function() {
if
(
jQuery
.
urlParam
(
'pa_format'
)
!=
''
||
jQuery
.
urlParam
(
'pa_couleur'
)
!=
''
||
jQuery
.
urlParam
(
'pa_matiere'
)
!=
''
){
jQuery
(
'.list-animation section'
).
each
(
function
()
{
if
(
jQuery
(
this
).
find
(
'article.selected'
).
length
==
0
)
{
jQuery
(
this
).
hide
();
}
});*/
});
}
jQuery
(
'.filter-bloc '
).
each
(
function
()
{
if
(
jQuery
(
this
).
find
(
'.bloc-content'
).
length
==
0
)
{
jQuery
(
this
).
hide
();
}
});
});
});
\ No newline at end of file
jQuery
.
urlParam
=
function
(
name
){
var
results
=
new
RegExp
(
'[
\
?&]'
+
name
+
'=([^&#]*)'
).
exec
(
window
.
location
.
href
);
return
results
[
1
]
||
0
;
}
\ No newline at end of file
wp-content/themes/nap/functions.php
View file @
6c46b2a2
<?php
@
ini_set
(
'upload_max_size'
,
'64M'
);
@
ini_set
(
'post_max_size'
,
'64M'
);
@
ini_set
(
'max_execution_time'
,
'300'
);
...
...
@@ -24,10 +23,11 @@ function get_zones($post_ID = 157) {
function
nap_enqueue_scripts
()
{
// Enqueue jQuery UI and autocomplete
wp_enqueue_script
(
'jquery-ui-core'
);
wp_enqueue_script
(
'jquery-ui-autocomplete'
);
wp_enqueue_script
(
'jquery-ui-core'
);
wp_enqueue_script
(
'jquery-ui-autocomplete'
);
}
add_action
(
'wp_enqueue_scripts'
,
'nap_enqueue_scripts'
);
add_action
(
'wp_enqueue_scripts'
,
'nap_enqueue_scripts'
);
//Dequeue CSS
function
nap_dequeue_unnecessary_css
()
{
...
...
@@ -155,7 +155,7 @@ add_action('woocommerce_product_after_variable_attributes', 'nap_variation_setti
function
nap_variation_settings_fields
(
$loop
,
$variation_data
,
$variation
)
{
// Gencode
woocommerce_wp_text_input
(
...
...
@@ -182,54 +182,49 @@ function nap_variation_settings_fields($loop, $variation_data, $variation) {
)
)
);
$option
=
nap_post_type_listing
(
'fiche_technique'
);
woocommerce_wp_text_input
(
array
(
'id'
=>
'fiche_var_auto_'
.
$variation
->
ID
,
'name'
=>
'fiche_var_auto_'
.
$variation
->
ID
,
'value'
=>
get_post_meta
(
$variation
->
ID
,
'fiche_var_auto'
,
true
),
'label'
=>
__
(
'Fiche technique'
,
'woocommerce'
),
)
);
?>
$option
=
nap_post_type_listing
(
'fiche_technique'
);
woocommerce_wp_text_input
(
array
(
'id'
=>
'fiche_var_auto_'
.
$variation
->
ID
,
'name'
=>
'fiche_var_auto_'
.
$variation
->
ID
,
'value'
=>
get_post_meta
(
$variation
->
ID
,
'fiche_var_auto'
,
true
),
'label'
=>
__
(
'Fiche technique'
,
'woocommerce'
),
)
)
;
?>
<script
type=
"text/javascript"
>
jQuery
(
document
).
ready
(
function
(){
var
posts
=
<?php
echo
json_encode
(
$option
);
?>
;
var
data
=
[];
jQuery
.
each
(
posts
,
function
(
index
,
value
)
{
data
.
push
({
'label'
:
value
,
'value'
:
index
});
});
jQuery
(
'input[name="fiche_var_auto_
<?php
echo
$variation
->
ID
?>
"]'
).
click
(
function
()
{
jQuery
(
this
).
val
(
''
);
});
jQuery
(
'input[name="fiche_var_auto_
<?php
echo
$variation
->
ID
?>
"]'
).
autocomplete
({
jQuery
(
document
).
ready
(
function
()
{
var
posts
=
<?php
echo
json_encode
(
$option
);
?>
;
var
data
=
[];
jQuery
.
each
(
posts
,
function
(
index
,
value
)
{
data
.
push
({
'label'
:
value
,
'value'
:
index
});
});
jQuery
(
'input[name="fiche_var_auto_
<?php
echo
$variation
->
ID
?>
"]'
).
click
(
function
()
{
jQuery
(
this
).
val
(
''
);
});
jQuery
(
'input[name="fiche_var_auto_
<?php
echo
$variation
->
ID
?>
"]'
).
autocomplete
({
source
:
data
,
minLength
:
1
,
select
:
function
(
event
,
ui
)
{
event
.
preventDefault
();
event
.
preventDefault
();
jQuery
(
this
).
val
(
ui
.
item
.
label
);
jQuery
(
"#_var_fiche_
<?php
echo
$variation
->
ID
?>
"
).
val
(
ui
.
item
.
value
);
jQuery
(
"#_var_fiche_
<?php
echo
$variation
->
ID
?>
"
).
val
(
ui
.
item
.
value
);
}
});
});
});
</script>
<?php
woocommerce_wp_hidden_input
(
array
(
'id'
=>
'_var_fiche_'
.
$variation
->
ID
,
'label'
=>
__
(
'Fiche technique'
,
'woocommerce'
),
'value'
=>
get_post_meta
(
$variation
->
ID
,
'_var_fiche'
,
true
),
'name'
=>
'_var_fiche_'
.
$variation
->
ID
,
)
);
woocommerce_wp_hidden_input
(
array
(
'id'
=>
'_var_fiche_'
.
$variation
->
ID
,
'label'
=>
__
(
'Fiche technique'
,
'woocommerce'
),
'value'
=>
get_post_meta
(
$variation
->
ID
,
'_var_fiche'
,
true
),
'name'
=>
'_var_fiche_'
.
$variation
->
ID
,
)
);
}
// Save Variation Settings
...
...
@@ -249,18 +244,16 @@ function nap_save_variation_settings_fields($variation_id) {
}
// Select fiches techniques
$var_fiche
=
$_POST
[
'_var_fiche_'
.
$variation_id
];
$var_fiche
=
$_POST
[
'_var_fiche_'
.
$variation_id
];
if
(
!
empty
(
$var_fiche
))
{
update_post_meta
(
$variation_id
,
'_var_fiche'
,
esc_attr
(
$var_fiche
));
}
$select_fiche
=
$_POST
[
'fiche_var_auto_'
.
$variation_id
];
if
(
!
empty
(
$select_fiche
)
)
{
update_post_meta
(
$variation_id
,
'fiche_var_auto'
,
esc_attr
(
$select_fiche
)
);
}
$select_fiche
=
$_POST
[
'fiche_var_auto_'
.
$variation_id
];
if
(
!
empty
(
$select_fiche
))
{
update_post_meta
(
$variation_id
,
'fiche_var_auto'
,
esc_attr
(
$select_fiche
));
}
}
function
nap_load_variation_settings_fields
(
$variations_id
)
{
...
...
@@ -328,12 +321,12 @@ function nap_menu() {
if
(
$sub_cats
)
{
$class
=
''
;
foreach
(
$sub_cats
as
$key
=>
$sub_category
)
{
if
(
$key
==
0
)
$calss
=
'active'
;
else
$calss
=
''
;
$menu
.=
'<li data-cover = "'
.
nap_category_image
(
$sub_category
->
term_id
)
.
'"><a class="'
.
$calss
.
'" href="#cat'
.
$sub_category
->
term_id
.
'">'
.
$sub_category
->
name
.
'</a></li>'
;
$menu
.=
'<li data-cover = "'
.
nap_category_image
(
$sub_category
->
term_id
)
.
'"><a class="'
.
$calss
.
'" href="#cat'
.
$sub_category
->
term_id
.
'">'
.
$sub_category
->
name
.
'</a></li>'
;
}
}
...
...
@@ -349,8 +342,8 @@ function nap_variation_url($variationID) {
$variable_product
=
wc_get_product
(
$variationID
);
$couleur
=
$variable_product
->
get_attribute
(
'couleur'
);
$color_url
=
get_term_by
(
'slug'
,
$couleur
,
'pa_couleur'
);
$format
=
$variable_product
->
get_attribute
(
'format'
);
$color_url
=
get_term_by
(
'slug'
,
$couleur
,
'pa_couleur'
);
$format
=
$variable_product
->
get_attribute
(
'format'
);
$format_url
=
get_term_by
(
'slug'
,
$format
,
'pa_format'
);
$url
=
'?attribute_couleur='
.
$color_url
->
slug
.
'&attribute_format='
.
$format_url
->
slug
.
'&variation_id='
.
$variationID
;
return
preg_replace
(
'/\s+/'
,
''
,
$url
);
...
...
@@ -366,31 +359,28 @@ function nap_variation_color($variationID) {
return
$color
;
}
function
nap_color_attribute
(
$name
){
$term
=
get_term_by
(
'slug'
,
$name
,
'pa_couleur'
);
function
nap_color_attribute
(
$name
)
{
$term
=
get_term_by
(
'slug'
,
$name
,
'pa_couleur'
);
$termID
=
$term
->
term_id
;
$color
=
get_field
(
'couleurs'
,
'pa_couleur_'
.
$termID
);
return
$color
;
}
function
nap_icon_format
(
$name
){
$icons
=
array
();
$term
=
get_term_by
(
'slug'
,
$name
,
'pa_format'
);
function
nap_icon_format
(
$name
)
{
$icons
=
array
();
$term
=
get_term_by
(
'slug'
,
$name
,
'pa_format'
);
$termID
=
$term
->
term_id
;
$active
=
get_field
(
'format_icone_active'
,
'pa_format_'
.
$termID
);
$inactive
=
get_field
(
'format_icone_inactive'
,
'pa_format_'
.
$termID
);
$active
=
get_field
(
'format_icone_active'
,
'pa_format_'
.
$termID
);
$inactive
=
get_field
(
'format_icone_inactive'
,
'pa_format_'
.
$termID
);
$iconHeight
=
get_field
(
'hauteur_icone'
,
'pa_format_'
.
$termID
);
$iconWidth
=
get_field
(
'largeur_icone'
,
'pa_format_'
.
$termID
);
$icons
[
'active'
]
=
$active
;
$icons
[
'inactive'
]
=
$inactive
;
$icons
[
'height'
]
=
$iconHeight
;
$icons
[
'width'
]
=
$iconWidth
;
return
$icons
;
$icons
[
'active'
]
=
$active
;
$icons
[
'inactive'
]
=
$inactive
;
$icons
[
'height'
]
=
$iconHeight
;
$icons
[
'width'
]
=
$iconWidth
;
return
$icons
;
}
function
nap_distinct_color_variations
(
$variations
)
{
...
...
@@ -405,11 +395,9 @@ function nap_distinct_color_variations($variations) {
return
$var_colors
;
}
function
nap_variation_format
(
$variationID
)
{
$variable_product
=
wc_get_product
(
$variationID
);
return
$variable_product
->
get_attribute
(
'format'
);
}
function
nap_distinct_format_variations
(
$variations
)
{
...
...
@@ -423,20 +411,35 @@ function nap_distinct_format_variations($variations) {
$var_format
[
$termID
]
=
$format_name
;
endif
;
endforeach
;
// print_r($var_format);
// print_r($var_format);
return
$var_format
;
}
function
nap_filter_attribute
(
$postID
,
$search
,
$attribute
,
$color
=
false
)
{
if
(
isset
(
$search
)
&&
$search
!=
''
)
{
$tab_attr
=
get_the_terms
(
$postID
,
$attribute
);
/*function nap_image_resize($image,$size){
$ext = substr($image, strrpos($image, "."));
$url = substr($image, 0, strrpos($image, "."));
return $newimage = $url . "-".$size."x".$size. $ext;
}*/
$filter
=
"hidden"
;
if
(
is_array
(
$tab_attr
))
{
foreach
(
$tab_attr
as
$key
=>
$value
)
{
if
(
$color
)
{
$code
=
nap_color_attribute
(
$value
->
slug
);
if
(
$code
!=
''
&&
stristr
(
$search
,
$code
))
{
$filter
=
"selected"
;
}
}
else
{
if
(
stristr
(
$search
,
$value
->
name
))
{
$filter
=
"selected"
;
}
}
}
}
}
return
$filter
;
}
function
nap_get_item
(
$post_ID
,
$args
=
null
,
$current_page
=
''
,
$options
=
null
,
$search
=
null
)
{
function
nap_get_item
(
$post_ID
,
$args
=
null
,
$current_page
=
''
,
$options
=
null
,
$search
=
null
)
{
$link
=
$image
=
$size
=
''
;
if
(
isset
(
$options
))
{
if
(
$options
[
'dwnldLink'
])
{
...
...
@@ -452,38 +455,57 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
}
}
if
(
isset
(
$search
[
'pa_couleur'
])
&&
$search
[
'pa_couleur'
]
!=
''
){
$colors_value
=
get_the_terms
(
$post_ID
,
'pa_couleur'
);
$filter
=
"hidden"
;
if
(
is_array
(
$colors_value
)){
foreach
(
$colors_value
as
$key
=>
$value
)
{
$code
=
nap_color_attribute
(
$value
->
slug
);
if
(
$code
!=
''
&&
stristr
(
$search
[
'pa_couleur'
],
$code
))
{
$filter
=
"selected"
;
if
(
isset
(
$search
[
'pa_couleur'
])
&&
$search
[
'pa_couleur'
]
!=
''
)
{
$colors_value
=
get_the_terms
(
$post_ID
,
'pa_couleur'
);
$filter
=
"hidden"
;
if
(
is_array
(
$colors_value
))
{
foreach
(
$colors_value
as
$key
=>
$value
)
{
$code
=
nap_color_attribute
(
$value
->
slug
);
if
(
$code
!=
''
&&
stristr
(
$search
[
'pa_couleur'
],
$code
))
{
$filter
=
"selected"
;
}
}
}
}
/*$attributes = array('Univers' => 'pa_univers', 'Matiére' => 'pa_matiere', 'Format' => 'pa_format', 'Couleurs' => 'pa_couleur');
foreach ($attributes as $key => $value) :
if($value = 'pa_couleur' )
$filter= nap_filter_attribute($post_ID,$search[$value],$value,true);
else
$filter= nap_filter_attribute($post_ID,$search[$value],$value);
endforeach;*/
if
(
isset
(
$search
[
'pa_format'
])
&&
$search
[
'pa_format'
]
!=
''
)
{
$format_value
=
get_the_terms
(
$post_ID
,
'pa_format'
);
$filter
=
"hidden"
;
if
(
is_array
(
$format_value
))
{
foreach
(
$format_value
as
$key
=>
$value
)
{
if
(
stristr
(
$search
[
'pa_format'
],
$value
->
name
))
{
$filter
=
"selected"
;
}
}
}
}
}
if
(
isset
(
$search
[
'pa_format'
])
&&
$search
[
'pa_format'
]
!=
''
){
$format_value
=
get_the_terms
(
$post_ID
,
'pa_format'
);
$filter
=
"hidden"
;
if
(
is_array
(
$format_value
)){
foreach
(
$format_value
as
$key
=>
$value
)
{
if
(
stristr
(
$search
[
'pa_format'
],
$value
->
name
))
{
$filter
=
"selected"
;
}
if
(
isset
(
$search
[
'pa_matiere'
])
&&
$search
[
'pa_matiere'
]
!=
''
)
{
$format_value
=
get_the_terms
(
$post_ID
,
'pa_matiere'
);
$filter
=
"hidden"
;
if
(
is_array
(
$format_value
))
{
foreach
(
$format_value
as
$key
=>
$value
)
{
if
(
stristr
(
$search
[
'pa_matiere'
],
$value
->
name
))
{
$filter
=
"selected"
;
}
}
}
}
}
if
(
isset
(
$filter
))
$class
=
$filter
;
$nap_article
=
'<article class = " visible row '
.
$class
.
'">
}
if
(
isset
(
$filter
))
$class
=
$filter
;
$nap_article
=
'<article class = " visible row '
.
$class
.
'">
<a href="#"></a>
<figure data-bg = "" class = "'
.
$size
.
' transition">
<div class="abs-full article-bg transition"></div>'
;
...
...
@@ -493,20 +515,18 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
$nap_article
.=
'<ul class = "clearfix">'
;
$variations
=
get_posts
(
$args
);
$temp_colors
=
array
();
if
(
!
empty
(
$variations
))
{
if
(
!
empty
(
$variations
))
{
foreach
(
$variations
as
$key
=>
$value
)
{
$color
=
nap_variation_color
(
$value
->
ID
);
$format
=
nap_variation_format
(
$value
->
ID
);
if
(
!
in_array
(
$color
,
$temp_colors
))
{
$temp_colors
[]
=
$color
;
$nap_article
.=
'<li data-link = "'
.
get_permalink
(
$post_ID
)
.
nap_variation_url
(
$value
->
ID
)
.
'" data-image = "'
.
get_the_post_thumbnail_url
(
$value
->
ID
,
'thumbnail'
)
.
'" data-color = "'
.
$color
.
'" data-format = "'
.
$format
.
'"></li> '
;
$nap_article
.=
'<li data-link = "'
.
get_permalink
(
$post_ID
)
.
nap_variation_url
(
$value
->
ID
)
.
'" data-image = "'
.
get_the_post_thumbnail_url
(
$value
->
ID
,
'thumbnail'
)
.
'" data-color = "'
.
$color
.
'" data-format = "'
.
$format
.
'"></li> '
;
}
}
}
else
{
$nap_article
.=
'<li data-link = "'
.
get_permalink
(
$post_ID
)
.
'" data-image = "'
.
get_the_post_thumbnail_url
(
$value
->
ID
,
'thumbnail'
)
.
'" data-color = "'
.
get_post_thumbnail_id
(
$post_ID
)
.
'" data-format = ""></li> '
;
}
else
{
$nap_article
.=
'<li data-link = "'
.
get_permalink
(
$post_ID
)
.
'" data-image = "'
.
get_the_post_thumbnail_url
(
$value
->
ID
,
'thumbnail'
)
.
'" data-color = "'
.
get_post_thumbnail_id
(
$post_ID
)
.
'" data-format = ""></li> '
;
}
$nap_article
.=
'</ul>'
;
endif
;
...
...
@@ -519,144 +539,137 @@ function nap_get_item($post_ID, $args = null, $current_page = '', $options = nul
remove_action
(
'woocommerce_after_single_product_summary'
,
'woocommerce_output_related_products'
,
20
);
function
nap_upload_image
(
$img
){
function
nap_upload_image
(
$img
)
{
return
trim
(
strtolower
(
$img
));
}
function
nap_variable_meta
(
$varID
,
$meta
){
return
get_post_meta
(
$varID
,
'_'
.
$meta
,
true
);
}
add_action
(
'wp_login_failed'
,
'my_front_end_login_fail'
);
// hook failed login
function
my_front_end_login_fail
(
$username
)
{
$referrer
=
$_SERVER
[
'HTTP_REFERER'
];
// where did the post submission come from?
// if there's a valid referrer, and it's not the default log-in screen
if
(
!
empty
(
$referrer
)
&&
!
strstr
(
$referrer
,
'wp-login'
)
&&
!
strstr
(
$referrer
,
'wp-admin'
)
)
{
wp_redirect
(
$referrer
.
'?login=failed'
);
// let's append some information (login=failed) to the URL for the theme to use
exit
;
}
function
nap_variable_meta
(
$varID
,
$meta
)
{
return
get_post_meta
(
$varID
,
'_'
.
$meta
,
true
);
}
add_action
(
'wp_login_failed'
,
'my_front_end_login_fail'
);
// hook failed login
function
my_front_end_login_fail
(
$username
)
{
$referrer
=
$_SERVER
[
'HTTP_REFERER'
];
// where did the post submission come from?
// if there's a valid referrer, and it's not the default log-in screen
if
(
!
empty
(
$referrer
)
&&
!
strstr
(
$referrer
,
'wp-login'
)
&&
!
strstr
(
$referrer
,
'wp-admin'
))
{
wp_redirect
(
$referrer
.
'?login=failed'
);
// let's append some information (login=failed) to the URL for the theme to use
exit
;
}
}
add_action
(
'woocommerce_product_options_general_product_data'
,
'nap_general_product_data_custom_field'
);
add_action
(
'woocommerce_product_options_general_product_data'
,
'nap_general_product_data_custom_field'
);
function
nap_general_product_data_custom_field
(
$post_id
)
{
woocommerce_wp_text_input
(
array
(
'id'
=>
'_gencod_simple'
,
'label'
=>
__
(
'Gencod(EAN13)'
,
'woocommerce'
),
)
);
woocommerce_wp_text_input
(
array
(
'id'
=>
'_itf14_simple'
,
'label'
=>
__
(
'ITF 14'
,
'woocommerce'
),
)
);
$option
=
nap_post_type_listing
(
'fiche_technique'
);
woocommerce_wp_text_input
(
array
(
'id'
=>
'fiche_simple_auto'
,
'name'
=>
'fiche_simple_auto'
,
'label'
=>
__
(
'Fiche technique'
,
'woocommerce'
),
)
);
?>
woocommerce_wp_text_input
(
array
(
'id'
=>
'_gencod_simple'
,
'label'
=>
__
(
'Gencod(EAN13)'
,
'woocommerce'
),
)
);
woocommerce_wp_text_input
(
array
(
'id'
=>
'_itf14_simple'
,
'label'
=>
__
(
'ITF 14'
,
'woocommerce'
),
)
);
$option
=
nap_post_type_listing
(
'fiche_technique'
);
woocommerce_wp_text_input
(
array
(
'id'
=>
'fiche_simple_auto'
,
'name'
=>
'fiche_simple_auto'
,
'label'
=>
__
(
'Fiche technique'
,
'woocommerce'
),
)
);
?>
<script
type=
"text/javascript"
>
jQuery
(
document
).
ready
(
function
(){
var
posts
=
<?php
echo
json_encode
(
$option
);
?>
;
var
data
=
[];
jQuery
.
each
(
posts
,
function
(
index
,
value
)
{
data
.
push
({
'label'
:
value
,
'value'
:
index
});
});
jQuery
(
'input[name="fiche_simple_auto"]'
).
click
(
function
()
{
jQuery
(
this
).
val
(
''
);
});
jQuery
(
'input[name="fiche_simple_auto"]'
).
autocomplete
({
jQuery
(
document
).
ready
(
function
()
{
var
posts
=
<?php
echo
json_encode
(
$option
);
?>
;
var
data
=
[];
jQuery
.
each
(
posts
,
function
(
index
,
value
)
{
data
.
push
({
'label'
:
value
,
'value'
:
index
});
});
jQuery
(
'input[name="fiche_simple_auto"]'
).
click
(
function
()
{
jQuery
(
this
).
val
(
''
);
});
jQuery
(
'input[name="fiche_simple_auto"]'
).
autocomplete
({
source
:
data
,
minLength
:
1
,
select
:
function
(
event
,
ui
)
{
event
.
preventDefault
();
event
.
preventDefault
();
jQuery
(
this
).
val
(
ui
.
item
.
label
);
jQuery
(
"#_fiche_simple"
).
val
(
ui
.
item
.
value
);
jQuery
(
"#_fiche_simple"
).
val
(
ui
.
item
.
value
);
}
});
});
});
</script>
<?php
woocommerce_wp_hidden_input
(
array
(
'id'
=>
'_fiche_simple'
,
'label'
=>
__
(
'Fiche technique'
,
'woocommerce'
),
'name'
=>
'_fiche_simple'
,
woocommerce_wp_hidden_input
(
array
(
'id'
=>
'_fiche_simple'
,
'label'
=>
__
(
'Fiche technique'
,
'woocommerce'
),
'name'
=>
'_fiche_simple'
,
)
);
}
)
);
}
add_action
(
'woocommerce_process_product_meta'
,
'nap_save_general_proddata_custom_field'
);
function
nap_save_general_proddata_custom_field
(
$post_id
)
{
$select_fiche
=
$_POST
[
'fiche_simple_auto'
];
if
(
!
empty
(
$select_fiche
)
)
{
update_post_meta
(
$post_id
,
'fiche_simple_auto'
,
esc_attr
(
$select_fiche
)
);
}
$id_fiche
=
$_POST
[
'_fiche_simple'
];
if
(
!
empty
(
$id_fiche
)
)
{
update_post_meta
(
$post_id
,
'_fiche_simple'
,
esc_attr
(
$id_fiche
)
);
}
$text_gencod
=
$_POST
[
'_gencod_simple'
];
if
(
!
empty
(
$text_gencod
)
)
{
update_post_meta
(
$post_id
,
'_gencod_simple'
,
esc_attr
(
$text_gencod
)
);
}
$text_itf14
=
$_POST
[
'_itf14_simple'
];
if
(
!
empty
(
$text_itf14
)
)
{
update_post_meta
(
$post_id
,
'_itf14_simple'
,
esc_attr
(
$text_itf14
)
);
}
add_action
(
'woocommerce_process_product_meta'
,
'nap_save_general_proddata_custom_field'
);
function
nap_save_general_proddata_custom_field
(
$post_id
)
{
$select_fiche
=
$_POST
[
'fiche_simple_auto'
];
if
(
!
empty
(
$select_fiche
))
{
update_post_meta
(
$post_id
,
'fiche_simple_auto'
,
esc_attr
(
$select_fiche
));
}
$id_fiche
=
$_POST
[
'_fiche_simple'
];
if
(
!
empty
(
$id_fiche
))
{
update_post_meta
(
$post_id
,
'_fiche_simple'
,
esc_attr
(
$id_fiche
));
}
$text_gencod
=
$_POST
[
'_gencod_simple'
];
if
(
!
empty
(
$text_gencod
))
{
update_post_meta
(
$post_id
,
'_gencod_simple'
,
esc_attr
(
$text_gencod
));
}
$text_itf14
=
$_POST
[
'_itf14_simple'
];
if
(
!
empty
(
$text_itf14
))
{
update_post_meta
(
$post_id
,
'_itf14_simple'
,
esc_attr
(
$text_itf14
));
}
}
//MS 2017-08-02 : Get referrer
function
externe_referrer
(){
function
externe_referrer
()
{
$url
=
$_SERVER
[
'HTTP_REFERER'
];
$postid
=
url_to_postid
(
$url
);
$ref
=
false
;
$uri
=
$_SERVER
[
'HTTP_HOST'
]
.
$_SERVER
[
'REQUEST_URI'
];
$postid
=
url_to_postid
(
$url
);
$ref
=
false
;
$uri
=
$_SERVER
[
'HTTP_HOST'
]
.
$_SERVER
[
'REQUEST_URI'
];
$pageWasRefreshed
=
isset
(
$_SERVER
[
'HTTP_CACHE_CONTROL'
])
&&
$_SERVER
[
'HTTP_CACHE_CONTROL'
]
===
'max-age=0'
;
if
(
$pageWasRefreshed
||
empty
(
$url
)
)
{
$ref
=
true
;
if
(
$pageWasRefreshed
||
empty
(
$url
)
)
{
$ref
=
true
;
}
return
$ref
;
}
function
get_logged_user
(){
if
(
is_user_logged_in
()
)
{
global
$current_user
;
get_currentuserinfo
();
echo
$current_user
->
user_lastname
.
' '
.
$current_user
->
user_firstname
;
echo
'<span class = "logout"><a href="'
.
wp_logout_url
(
get_permalink
())
.
'">déconnexion</a></span>'
;
}
else
{
echo
'<a class="login" href="#">accès pro</a>'
;
return
$ref
;
}
function
get_logged_user
()
{
if
(
is_user_logged_in
())
{
global
$current_user
;
get_currentuserinfo
();
echo
$current_user
->
user_lastname
.
' '
.
$current_user
->
user_firstname
;
echo
'<span class = "logout"><a href="'
.
wp_logout_url
(
get_permalink
())
.
'">déconnexion</a></span>'
;
}
else
{
echo
'<a class="login" href="#">accès pro</a>'
;
}
}
function
nap_attribute_by_category
(
$categorie
,
$attr
){
function
nap_attribute_by_category
(
$categorie
,
$attr
)
{
$args
=
array
(
'post_type'
=>
array
(
'product'
,
'product_variation'
),
'numberposts'
=>
-
1
,
...
...
@@ -666,28 +679,42 @@ function nap_attribute_by_category($categorie, $attr){
'field'
=>
'id'
,
'terms'
=>
$categorie
,
'operator'
=>
'IN'
,
)
)
);
)
);
$products
=
get_posts
(
$args
);
$attribute
=
array
();
$attribute
=
array
();
foreach
(
$products
as
$key
=>
$value
)
{
$list_attr
=
woocommerce_get_product_terms
(
$value
->
ID
,
$attr
,
'names'
);
foreach
(
$list_attr
as
$key
=>
$value
)
{
$attribute
[]
=
$value
;
}
$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
);
add_image_size
(
'wordpress-thumbnail'
,
200
,
200
,
FALSE
);
function
nap_selected_filter
(
$search
,
$attribute
)
{
if
(
isset
(
$search
)
&&
stristr
(
$search
,
$attribute
))
:
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
}
add_action
(
'trash_fiche_technique'
,
'nap_trash_fiche_technique'
,
1
,
1
);
function
nap_trash_fiche_technique
(
$post_id
)
{
$post
=
get_post
(
$post_id
);
global
$wpdb
;
$table
=
$wpdb
->
prefix
.
'postmeta'
;
$wpdb
->
delete
(
$table
,
array
(
'meta_key'
=>
'_fiche_simple'
,
'meta_value'
=>
$post_id
));
$wpdb
->
delete
(
$table
,
array
(
'meta_key'
=>
'_var_fiche'
,
'meta_value'
=>
$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
));
}
wp-content/themes/nap/woocommerce/archive-product.php
View file @
6c46b2a2
...
...
@@ -125,7 +125,12 @@ $child_category = get_terms('product_cat', array('parent' => $cateID, 'child_of'
</div>
<div
class=
"right-panel right"
>
<div
class=
"panel panel-content list-animation"
>
<?php
if
(
$_GET
[
'pa_couleur'
]
!=
''
||
$_GET
[
'pa_format'
]
!=
''
||
$_GET
[
'pa_matiere'
]
!=
''
)
:?>
<
span
style
=
" position: relative; display: block;top: 80px;font-size: 11px;"
class
="
search_result
">Résultat de votre recherche :</span>
<?php endif;?>
<?php foreach (
$child_category
as
$key
=>
$value
) : ?>
<section id = "
cat
<?
php
echo
$value
->
term_id
?>
">
<h2
class=
"crete small-title"
>
<?php
echo
$value
->
name
?>
</h2>
<div
class=
"cover-mobile display--only-mobile animated fadeInUp"
style =
"background-image: url('
<?php
echo
nap_category_image
(
$value
->
term_id
)
?>
')"
>
...
...
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